REST (Representational State Transfer) is an architectural style for designing networked APIs that uses HTTP methods to perform operations on resources identified by URLs. RESTful APIs treat everything as a resource (a user, a product, an order) that can be created, read, updated, and deleted through standardized HTTP verbs.
How It Works
REST maps CRUD operations to HTTP methods: GET retrieves resources, POST creates new ones, PUT replaces existing resources entirely, PATCH applies partial updates, and DELETE removes resources. URLs identify resources hierarchically: /users/42/orders/7 refers to order 7 belonging to user 42.
Responses typically use JSON format with appropriate HTTP status codes: 200 for success, 201 for creation, 404 for not found, 422 for validation errors, and 500 for server failures. Proper status codes let clients handle responses programmatically without parsing error messages.
REST is stateless; each request contains all information needed to process it. The server does not remember previous requests, which simplifies scaling because any server instance can handle any request.
Why It Matters
REST's power lies in its simplicity and universality. Any HTTP client in any programming language can consume a REST API. The concepts map directly to how the web already works. New developers understand GET and POST intuitively because browsers use them for every page load and form submission.
REST APIs also enable clean separation between frontend and backend. Multiple clients (web app, mobile app, third-party integrations) can consume the same API without backend changes.
In Practice
A well-designed REST API for a task manager might expose: GET /tasks returns all tasks, POST /tasks creates a new task with title and description in the request body, PATCH /tasks/15 updates task 15's status to complete, and DELETE /tasks/15 removes it. Filtering uses query parameters: GET /tasks?status=pending&assignee=sarah.
Pro Tips
Use plural nouns for resource names, never verbs. Nest resources to show relationships but keep nesting shallow (maximum two levels). Implement pagination for list endpoints from day one because adding it later breaks clients. Support filtering, sorting, and field selection through query parameters.