Skip to content

Instantly share code, notes, and snippets.

@eiri
Last active May 19, 2017 13:34
Show Gist options
  • Save eiri/feac058a9a241236b3685c298cdad145 to your computer and use it in GitHub Desktop.
Save eiri/feac058a9a241236b3685c298cdad145 to your computer and use it in GitHub Desktop.
REST Cheatsheet

REST Cheatshit

REST to CRUD

  • POST - create
  • GET - read
  • PUT - update (replace)
  • PATCH - update (partial)
  • DELETE - delete
  • HEAD - verify

Method-Safe-Idempotent

Method Safe Idempotent
GET
PUT
PATCH
DELETE
POST

REST Versioning

URL /api/v2/{uri} or header 'X-API-Version: 2.4'

Naming URI

  • /notes - list
  • /notes?filter="a" - list with attr
  • /notes/1 - uri
  • /notes/1?include_feature="a" - uri with attr

Using PATCH

Call PATCH with JSON payload with operation, field and optional value

Example:

{"operation": "replace", "field": "amount", "value": 200.12}

{"operation": "toggle", "field": "verified"}

{"operation": "increase", "field": "counter", "value": 12}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment