Fundamentals of REST API Design
Representational State Transfer (REST) is an architectural style that guides the design of networked applications. By adhering to a set of constraints, developers can create APIs that are…

A client receives a 201 Created response after sending a request. What does this status code indicate?
In a RESTful API, which constraint ensures that each request contains all information needed to process it, without relying on prior requests?
Which HTTP status code should a server return when a client tries to access a resource that does not exist?
A developer wants to update only the title of a blog post without sending the entire post data. Which HTTP method is most appropriate?
In the restaurant analogy, what component of an API corresponds to the waiter delivering the dish to the customer?
Which of the following best describes a private API?
When designing REST endpoints, why is it recommended to use nouns rather than verbs in the URL path?
A client sends a POST request with malformed JSON to an API. Which status code should the server return?
Which REST constraint allows an API to send executable JavaScript code to a client instead of just data?
Introduction to REST API Design
Representational State Transfer (REST) is an architectural style that guides the design of networked applications. By adhering to a set of constraints, developers can create APIs that are scalable, performant, and easy to consume. This course breaks down the fundamental concepts tested in a typical REST quiz, providing clear explanations, practical examples, and SEO‑friendly structure.
Choosing the Right HTTP Method
Retrieving Resources: GET
When a client needs to fetch a collection of resources—such as a list of users—the GET method is the correct choice. GET requests are safe (they do not modify server state) and idempotent (multiple identical requests produce the same result).
- GET: Retrieve data without side effects.
- POST: Create a new resource.
- PUT: Replace an entire resource.
- PATCH: Partially update a resource.
- DELETE: Remove a resource.
Creating Resources: POST and 201 Created
After a successful POST request, the server often returns the 201 Created status code. This indicates that a new resource has been successfully created and typically includes a Location header pointing to the newly created URI.
Example response:
HTTP/1.1 201 Created
Location: /users/123
Content-Type: application/json
{"id":123,"name":"Alice"}
Statelessness: The Core Constraint
One of the six REST constraints is statelessness. This means each request from a client must contain all the information necessary for the server to understand and process it, without relying on any stored context from previous requests.
Benefits of stateless design include:
- Improved scalability—servers can handle each request independently.
- Enhanced reliability—if a request fails, retrying it does not cause side effects.
- Simpler caching mechanisms.
Handling Errors with Appropriate Status Codes
Resource Not Found: 404 Not Found
When a client requests a resource that does not exist, the server should respond with 404 Not Found. This status code clearly communicates that the target URI is invalid or the resource has been removed.
Contrast with other common error codes:
- 400 Bad Request: The request syntax is malformed.
- 401 Unauthorized: Authentication is required but missing or invalid.
- 403 Forbidden: The client is authenticated but does not have permission.
Partial Updates with PATCH
When only a subset of a resource's fields needs to be changed—such as updating the title of a blog post—use the PATCH method. Unlike PUT, which expects the full representation of the resource, PATCH allows you to send just the changes, reducing bandwidth and minimizing the risk of unintentionally overwriting other fields.
Example PATCH payload:
{"title":"New Blog Title"}
Understanding API Analogy: The Waiter
In the classic restaurant analogy, the API response is comparable to the waiter delivering the dish to the customer. The request is the order placed, the server processes the order, and the response (the dish) is handed back to the client.
API Types: Public vs. Private
Private APIs
A private API is intended for use within a single organization. It enables internal services to communicate securely without exposing endpoints to external developers. Private APIs often handle sensitive data and are protected by internal authentication mechanisms.
Key characteristics:
- Restricted access—only employees or trusted services can call the API.
- Typically not documented publicly.
- Used for internal automation, data sharing, and micro‑service communication.
Designing Clean URLs: Nouns Over Verbs
RESTful URLs should represent resources, not actions. By using nouns (e.g., /users, /orders) and letting HTTP methods convey the operation, the API becomes more intuitive and aligns with the uniform interface constraint.
Incorrect example (verb in URL):
/createUser
Correct example (noun in URL):
/users
When a client sends a POST to /users, the server knows a new user is being created. When it sends a GET to /users/123, the server knows the client wants the representation of user 123.
Summary of Core Concepts
- HTTP Methods: GET for retrieval, POST for creation, PUT for full replacement, PATCH for partial updates, DELETE for removal.
- Status Codes: 201 Created (resource created), 404 Not Found (resource missing), 400 Bad Request (malformed request), 401 Unauthorized (authentication needed), 403 Forbidden (no permission).
- Statelessness: Every request must be self‑contained.
- API Responses: Analogous to a waiter delivering a dish.
- API Types: Private APIs serve internal needs; public APIs are open to external developers.
- URL Design: Use nouns to represent resources; let HTTP methods express actions.
Further Reading and Resources
To deepen your understanding of RESTful design, explore these authoritative sources:
- Roy Fielding's original dissertation – the foundation of REST.
- MDN Web Docs: HTTP Methods – detailed method specifications.
- RESTful API Tutorial – practical examples and best practices.
