What is REST?
REST (Representational State Transfer) is an architectural style for designing networked applications that uses HTTP requests to perform CRUD operations (Create, Read, Update, Delete) on resources identified by URLs. It emphasizes stateless communication and uniform interfaces.
Quick Facts
| Full Name | Representational State Transfer |
|---|---|
| Created | 2000 by Roy Fielding |
| Specification | Official Specification |
How REST Works
REST was defined by Roy Fielding in his 2000 doctoral dissertation. It provides a set of constraints that, when followed, create a scalable and maintainable web service. RESTful APIs use standard HTTP methods: GET (read), POST (create), PUT/PATCH (update), and DELETE (remove). Resources are represented in formats like JSON or XML. REST's stateless nature means each request contains all information needed to process it, making it highly scalable. While not a standard, REST has become the dominant architecture for web APIs.
Key Characteristics
- Stateless - each request is independent
- Uses standard HTTP methods (GET, POST, PUT, DELETE)
- Resources identified by URLs
- Supports multiple data formats (JSON, XML)
- Client-server architecture separation
- Cacheable responses for performance
Common Use Cases
- Web service APIs
- Mobile application backends
- Microservices communication
- Third-party integrations
- CRUD operations on resources
Example
RESTful API Endpoints:
Method Endpoint Description
GET /api/users List all users
GET /api/users/123 Get user by ID
POST /api/users Create new user
PUT /api/users/123 Update entire user
PATCH /api/users/123 Partial update
DELETE /api/users/123 Delete user
HTTP Response Codes:
200 OK - Successful GET/PUT/PATCH
201 Created - Successful POST
204 No Content - Successful DELETE
400 Bad Request - Invalid request
401 Unauthorized - Authentication required
404 Not Found - Resource not found
500 Server Error - Internal error
Request Example:
GET /api/users/123 HTTP/1.1
Host: api.example.com
Authorization: Bearer token123
Accept: application/json