What Is a REST API? Explained Simply
REST is the style almost every public API uses. Learn what REST means, the HTTP methods, and how to read an endpoint โ without the jargon.
A REST API is a web API that follows a set of conventions called REST (Representational State Transfer). It models everything as resources — users, orders, articles — each with its own URL, and uses standard HTTP methods to act on them. Most public APIs you will meet are REST or REST-ish.
Resources and methods
In REST, the URL names a thing and the HTTP method says what to do with it:
| GET /articles | List articles (read, safe, no side effects) |
| GET /articles/42 | Read one article |
| POST /articles | Create a new article (body carries the data) |
| PUT /articles/42 | Replace article 42 entirely |
| PATCH /articles/42 | Update some fields of article 42 |
| DELETE /articles/42 | Remove article 42 |
Sub-resources nest: GET /articles/42/comments lists the comments on article 42; POST /articles/42/comments adds one.
The other REST ideas
- Statelessness — each request carries everything the server needs (including auth). The server keeps no per-client session between calls, which makes REST APIs easy to scale.
- Standard status codes — 2xx success, 3xx redirect, 4xx your mistake, 5xx their mistake.
- Representations — the same resource can be sent as JSON, XML or HTML; the client asks via the
Acceptheader. In practice it is almost always JSON. - Cacheability — GET responses can be cached using
ETag/Cache-Controlheaders. - HATEOAS — responses include links to related actions. Widely described, rarely fully implemented.
A complete example
# create
curl -X POST https://api.example.com/v1/articles \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d '{"title": "Hello", "body": "..."}'
# -> 201 Created, Location: /v1/articles/99
# read it back
curl https://api.example.com/v1/articles/99 -H "Authorization: Bearer $KEY"
# -> 200 OK, { "id": 99, "title": "Hello", ... }
# delete it
curl -X DELETE https://api.example.com/v1/articles/99 -H "Authorization: Bearer $KEY"
# -> 204 No Content‘RESTful’ in the real world
Few APIs follow every REST constraint to the letter, and that is fine. Common pragmatic deviations: actions that don’t map to a resource (POST /articles/42/publish), filtering and pagination via query strings (?status=draft&page=2), and bulk endpoints. When people say ‘REST API’ today they usually mean ‘JSON over HTTP, organised around resources and methods’.
REST vs. the alternatives
- GraphQL — one endpoint; the client specifies exactly which fields it wants. Good for complex, nested data and mobile clients.
- gRPC — binary, contract-first, very fast; used for internal service-to-service calls.
- Webhooks — not a replacement but a complement: the server pushes events to you instead of you polling.
FAQ
What makes an API ‘RESTful’?
Organising it around resources with their own URLs, using HTTP methods for actions, staying stateless, and returning standard status codes. Full REST also requires hypermedia links, which most APIs skip.
Is every JSON API a REST API?
No — GraphQL and JSON-RPC also use JSON but are not REST. REST is about the resource-and-method structure, not the data format.
What status code should a successful POST return?
201 Created when a new resource is made (ideally with a Location header), or 200 OK / 204 No Content for actions that don’t create anything.
What is the difference between PUT and PATCH?
PUT replaces the whole resource with the body you send (omitted fields get cleared or defaulted). PATCH applies a partial update — only the fields you include change.
Keep going
Try it on a real API
๐ Explore free public APIs
Hundreds of free APIs, searchable by category, with auth & CORS at a glance.
Browse the directory โ