What is a REST API?
REST (Representational State Transfer) is an architectural style for designing networked APIs. It isn't a protocol or a library — it's a set of conventions, layered on top of HTTP, for how clients and servers talk about resources. When people say "build a REST API," they mean: model your data as resources with URLs, manipulate them with HTTP methods, and exchange representations (usually JSON). Done well, REST gives you an API that's predictable, cacheable, and easy for any client to consume.
Resources, not actions
The core mental shift: a REST API exposes nouns (resources), and you act on them with HTTP's verbs. The URL identifies what; the method says what to do with it.
RPC-style (avoid) | RESTful (prefer) |
|---|---|
|
|
|
|
|
|
|
|
The method ↔ CRUD mapping
Method | CRUD | On | On |
|---|---|---|---|
| Read | List all users | Fetch user 5 |
| Create | Create a user | — |
| Replace | — | Replace user 5 wholesale |
| Update | — | Partially update user 5 |
| Delete | — | Delete user 5 |
A representation is just data — usually JSON
// GET /users/5 → a JSON representation of the resource
{
"id": 5,
"name": "Ada Lovelace",
"email": "ada@example.com",
"createdAt": "2026-01-12T09:30:00Z"
}Statelessness — the defining constraint
Each request carries everything the server needs to handle it — credentials, parameters, body. The server keeps no client session state between requests. This is what lets you run many identical server instances behind a load balancer: any one can handle any request.
What makes an API "RESTful"
Resource-based URLs —
/articles/42/comments, not/getArticleComments.Proper HTTP methods — the verb is the method; respect their semantics.
Meaningful status codes —
200,201,404,422… not always200 { "ok": false }.Stateless requests — each one self-contained and independently routable.
Representations — exchange data (JSON), decoupled from internal storage.
Why REST won
Uses HTTP as-is — works with every browser, proxy, CDN, and HTTP client unchanged.
Cacheable —
GETs can be cached by the same infrastructure that caches web pages.Uniform & predictable — once you know the conventions, any REST API feels familiar.
Loose coupling — clients and servers evolve independently behind the contract.