One page

HTTP and REST APIs cheat sheet

What to keep at hand. If a line is not clear, go back to the matching lesson in the course.

Open the course: HTTP and REST APIs

Methods and statuses

WhatHow
ReadGET /users/:id
CreatePOST /users → 201
Update partPATCH /users/:id
DeleteDELETE /users/:id → 204
Don't know who you are401 Unauthorized
Know you, but no403 Forbidden

Client

WhatHow
JSON requestfetch(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(data) })
Checkingif (!res.ok) throw new Error("HTTP " + res.status)
Bodyawait res.json()

Cache, errors, real time

WhatHow
Cache for an hourCache-Control: max-age=3600
Don't storeCache-Control: no-store
Version checkIf-None-Match: "v42" → 304
Too many requests429 + Retry-After: 30
Events from the servernew EventSource("/events")

Other cheat sheets