What is a REST API?
A REST API (Representational State Transfer Application Programming Interface) is a set of rules that allows software programs to communicate over the web using standard HTTP. It is the most widely-adopted API design architecture in modern software development.
1 The 6 REST Constraints
An API is RESTful when it follows these architectural constraints defined by Roy Fielding in 2000:
- Client-Server: The UI and data storage concerns are separated. The client and server evolve independently.
- Stateless: Every request from client to server must contain all information needed to understand it. The server stores no session state between requests.
- Cacheable: Responses must define themselves as cacheable or non-cacheable to improve efficiency.
- Uniform Interface: A consistent, standardized way to interact with the server (resources, HTTP verbs, self-describing messages).
- Layered System: Clients cannot tell whether they are connected directly to the server or a middleware layer (load balancer, cache, gateway).
- Code on Demand (optional): Servers can send executable code to clients (e.g. JavaScript snippets).
2 How REST Works — The Request/Response Cycle
HTTP — A REST Request Example
--- REQUEST ---
GET /api/v1/users/42 HTTP/1.1
Host: api.example.com
Authorization: Bearer eyJhbGci...
Accept: application/json
--- RESPONSE ---
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: max-age=300
{
"id": 42,
"name": "Balaji Nayak",
"email": "balaji@example.com",
"role": "admin",
"createdAt": "2026-01-15T10:30:00Z"
}
3 REST vs Other API Styles
| Feature | REST | GraphQL | SOAP | gRPC |
|---|---|---|---|---|
| Protocol | HTTP | HTTP | HTTP/SMTP | HTTP/2 |
| Data Format | JSON/XML | JSON | XML | Protobuf |
| Flexibility | High | Very High | Low | Medium |
| Learning Curve | Low | Medium | High | Medium |
| Best For | Public APIs | Complex UIs | Enterprise | Microservices |
4 Code Challenge
Challenge: Use the browser's DevTools Network tab (or a tool like Postman) to inspect a REST API call to
https://jsonplaceholder.typicode.com/users/1. Identify the request method, status code, response headers, and the JSON body fields returned.