What is a REST API?
Short answer
A REST API is a way for programs to exchange data over HTTP. Each thing is a resource with a URL, you act on it with HTTP methods like GET, POST, PUT, PATCH, DELETE, and sometimes QUERY, and the server replies with data and a status code. Each request stands on its own.
Resources and URLs
In REST, everything is a resource addressed by a URL. /users is the collection of users; /users/42 is one specific user. You interact with these URLs rather than calling named functions.
Methods describe the action
GETreads a resource without changing itQUERYruns a safe, idempotent query with request content when the API supports itPOSTcreates a new resourcePUTorPATCHupdates an existing resourceDELETEremoves a resource
GET /users/42 -> 200 OK
{ "id": 42, "name": "Ada" }Status codes tell you what happened
The response includes an HTTP status code: 2xx for success, 4xx when the request was wrong, and 5xx when the server failed. See HTTP status codes for the full list.