REST
What is it?
REST is a style for designing web APIs around resources (like users or orders) accessed with standard HTTP methods.
Explain like I'm 5
Why was it created?
It gave the web a simple, consistent convention for APIs that reuses HTTP itself, instead of every service inventing its own rules.
Where is it used?
- Public web APIs
- Mobile app backends
- Microservice-to-microservice calls
- Browser front-end data fetching
Why should developers care?
REST is the most common API style on the web. Almost every developer reads or builds REST APIs.
How does it work?
Each resource has a URL. You act on it with HTTP methods (GET, POST, PUT, PATCH, DELETE) and exchange data (usually JSON). Status codes report the outcome, and requests are stateless.
Real-world example
A client sends GET /users/42 to fetch one user, or POST /users with a JSON body to create one, and reads the HTTP status code to know if it worked.
Common use cases
- CRUD APIs over HTTP
- Public developer APIs
- Server-to-server communication
- Front-end to back-end data exchange
Advantages
- Simple and widely understood
- Uses standard HTTP
- Stateless and cacheable
- Language-agnostic
Disadvantages
- Can over-fetch or under-fetch data
- Multiple round-trips for related data
- No built-in schema/type contract
When should you use it?
For straightforward resource-based APIs and public interfaces.
When should you avoid it?
When clients need flexible, precise queries (consider GraphQL) or low-latency streaming (consider gRPC).
Alternatives
Related terms
Interview questions
Beginner
- What HTTP methods does REST use?
- What does stateless mean?
Intermediate
- What's the difference between PUT and PATCH?
- What status code fits a created resource?
Senior
- How do you version a REST API without breaking clients?
- How would you design pagination?
Common misconceptions
- "Any JSON-over-HTTP API is RESTful" — true REST follows resource and statelessness conventions, not just JSON.
- "REST requires JSON" — REST is format-agnostic; JSON is just common.
Fun facts
- REST stands for Representational State Transfer.
- It was defined in Roy Fielding's year-2000 doctoral dissertation.
Timeline
- 2000 — Described in Roy Fielding's dissertation
Learning resources
Quick summary
REST is a convention for building web APIs around resources and standard HTTP methods, making them simple and predictable.
Cheat sheet
- Resources identified by URLs
- Standard HTTP verbs (GET/POST/PUT/DELETE)
- Stateless requests
- Status codes report outcomes