GET & POST
GET and POST are the two methods you will use most. They sit at opposite ends of the safety spectrum: GET only reads, while POST creates and is the least constrained method of all.
GET — safe and cacheable
Section titled “GET — safe and cacheable”A GET retrieves a representation of a resource and must never change server state. Because it is safe, responses can be cached and requests can be freely retried. A GET on a collection returns the list; a GET on an item returns that item or 404.
GET /articles/42 HTTP/1.1Accept: application/jsonA GET should never carry a meaningful request body, and must not have side effects — no “increment view count via GET”, or caches and prefetchers will surprise you.
POST — create and non-idempotent actions
Section titled “POST — create and non-idempotent actions”A POST submits data to a collection, typically creating a new resource. It is neither safe nor idempotent: sending the same POST twice usually creates two resources. On success, return 201 Created with a Location header pointing to the new resource.
Both, in a running API
Section titled “Both, in a running API”This Hono app exposes a collection you can read and append to. Open it in StackBlitz and try GET /articles, GET /articles/1, and POST /articles: