REST API
A REST API is an interface for exchanging data over HTTP that follows the REST architectural style described by Roy Fielding in 2000. Data is organized as resources with their own URLs, and clients work with them through standard HTTP methods such as GET, POST, PUT and DELETE.
What is a REST API?
A REST API is a web API that follows the REST (Representational State Transfer) architectural style: each piece of data is a resource with its own URL, and clients read or change it with standard HTTP methods. Responses usually come as JSON, and the server does not remember previous requests from the client.
For example, in an online store /products/42 is the address of product 42, GET /products/42 returns it, and DELETE /products/42 removes it. Most public APIs of web services, including the Stripe API, are built this way.
Where did REST come from?
REST was described by computer scientist Roy Fielding in his 2000 doctoral dissertation at the University of California, Irvine. Fielding was one of the authors of the HTTP/1.1 specification, and REST summarized the principles that had made the web scale. The terms "RESTful API" and "REST API" spread in the late 2000s, as web services moved away from heavier protocols.
What are the principles of REST?
Fielding defined six constraints:
- Client–server — the interface and data storage are separated.
- Stateless — each request carries everything needed to process it; the server keeps no client session between requests.
- Cacheable — responses state whether they may be cached.
- Uniform interface — resources are identified by URLs and handled through a standard set of operations.
- Layered system — proxies, load balancers and caches can sit between client and server unnoticed.
- Code on demand (optional) — the server may send code to run on the client.
How does a REST API work?
A request combines a method and a resource address. The main HTTP methods, as defined in RFC 9110:
| Method | Purpose | Safe | Idempotent |
|---|---|---|---|
| GET | Read a resource | Yes | Yes |
| POST | Create a resource or run an action | No | No |
| PUT | Replace a resource completely | No | Yes |
| PATCH | Change part of a resource | No | No |
| DELETE | Delete a resource | No | Yes |
"Idempotent" means that repeating the same request gives the same result as sending it once. The server answers with a status code: 200 OK, 201 Created, 204 No Content, 400 Bad Request, 401 Unauthorized, 404 Not Found, 429 Too Many Requests, 500 Internal Server Error.
A request and response:
curl -X POST https://api.example.com/v1/orders \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"product_id": 42, "quantity": 2}'
{ "id": 1017, "product_id": 42, "quantity": 2, "status": "created" }
The server returns 201 Created and the new order, which is now available at /v1/orders/1017.
How is REST different from SOAP and GraphQL?
- SOAP is a protocol with strict rules: XML messages in a special envelope and a formal contract (WSDL). It is still used in banking and government systems; REST is simpler and lighter.
- GraphQL uses one endpoint where the client describes exactly which fields it needs, which avoids fetching too much or too little data. REST uses many URLs and fixed response shapes, but is easier to cache through HTTP.
- gRPC sends compact binary messages over HTTP/2 and is popular for communication between internal services.
Sources
- Architectural Styles and the Design of Network-based Software Architectures, Chapter 5: REST — Roy T. Fielding, University of California, Irvine (accessed 30 November 2026)
- RFC 9110: HTTP Semantics — IETF (accessed 30 November 2026)
- HTTP request methods — MDN Web Docs (accessed 30 November 2026)
- HTTP response status codes — MDN Web Docs (accessed 30 November 2026)