Fun with Learning Technology
LearnCoursesQuestionsTracksToolsNewsExplorePractice
Fun with Learning Technology

A new problem, explained clearly, every day.

Subscribe
Learn
  • Lessons
  • Topics
  • News
  • Tools
  • Courses
  • Career tracks
  • Everything
Site
  • About
  • Contact
  • Support
  • Privacy
  • Terms
Get the daily one

One email per new problem. No spam.

Request a tutorial

Requests shape what gets made next.

Β© 2026 Fun with Learning TechnologyRSS
Homeβ€ΊCoursesβ€ΊREST API Designβ€ΊREST API Interview Questions

Interview Prep

REST API Interview Questions

This lesson covers the core architectural principles and practical design patterns essential for building robust RESTful services. Mastering these concepts allows developers to create predictable, scalable interfaces that decouple client and server concerns effectively. You should reach for this material when preparing for technical assessments that evaluate your ability to design clean, resource-oriented APIs.

The Semantics of HTTP Verbs

A common interview question involves justifying the choice of specific HTTP methods. REST relies on the uniform interface constraint, meaning we must use verbs that semantically match the intended action on a resource. GET is idempotent and safe, meaning it should never change state. POST is neither safe nor idempotent; it is used to create sub-resources or trigger non-standard actions. PUT requires the client to supply the full representation of the resource, making it idempotent because repeating the request results in the same state. PATCH is used for partial updates, offering efficiency when only specific fields need modification. Understanding these distinctions is critical because they allow intermediary components, like proxies and caches, to handle requests safely without understanding the internal business logic of your application, ensuring the entire distributed system remains consistent and predictable during operation.

// Standard resource manipulation
// GET /users/123 -> Fetch data
// POST /users -> Create new entry
// PUT /users/123 -> Replace entire record
// PATCH /users/123 -> Update fields
// DELETE /users/123 -> Remove resource

Designing Resource URIs

Interviewers often test your ability to design URI structures that are intuitive and hierarchical. A well-designed URI represents a resource, not an action. Use nouns, not verbs, to define the endpoint structure. Pluralization is generally preferred to maintain consistency, such as /orders rather than /order. Hierarchy should reflect ownership or containment, for example, /users/{userId}/orders/{orderId}. This structure makes the API self-documenting and predictable for the client developer. Avoid exposing database table names or implementation details in the URI path. By keeping the URI clean and focused purely on the resource identification, you maintain a level of abstraction that allows the backend team to refactor their internal data storage logic or microservice architecture without breaking existing client integrations. This consistency is the cornerstone of building long-lived, stable API contracts that stand the test of time.

// Good: Resource-based hierarchy
// GET /customers/50/invoices/2
// Bad: Verb-based or RPC-style
// GET /getInvoiceDetails?id=2

Effective Error Handling

Proper error handling is vital for developer experience and debugging. Never use a 200 OK status code to report a failure; this misleads the client and breaks automated error-handling middleware. Instead, use appropriate 4xx codes for client errors, like 400 for malformed requests or 401/403 for authentication and authorization failures. Use 5xx codes for server-side issues. The response body should provide machine-readable error details, such as a unique error code, a human-readable message, and perhaps a reference link to documentation. By providing consistent error structures, you allow client developers to write generic error interceptors that can act globally. This reduces code duplication on the client side and provides a clear contract on how to troubleshoot issues, which is often a point of heavy scrutiny in senior-level architectural design interviews and system reviews.

// Error response format
// HTTP 400 Bad Request
{
  "error_code": "INVALID_EMAIL",
  "message": "The provided email is malformed."
}

Statelessness and Scalability

REST mandates that communication be stateless. This means that every request from a client must contain all the information necessary for the server to understand and process it, including authentication tokens and metadata. The server should never rely on session state stored in memory between two different requests. The reasoning behind this is horizontal scalability; if the server is stateless, you can easily add more nodes behind a load balancer without needing to synchronize session memory across them. If the client needed to talk to the same server node every time, your scaling ability would be artificially capped by the memory limits of a single instance. Embracing statelessness simplifies the architecture, improves performance during high traffic, and ensures your application remains robust even if specific server instances fail or cycle frequently during deployment.

// stateless authentication via tokens
// Header: Authorization: Bearer <token>
// The server validates the token on every request
// without needing a local session lookup.

Versioning Strategies

Versioning is inevitable in long-term API development. Interviewers want to see that you understand how to evolve your API without breaking existing client integrations. The most common approaches include URI versioning, like /v1/users, or header-based versioning. URI versioning is widely used because it is simple to cache and debug, though some argue it modifies the resource identifier. Header-based versioning keeps the URI clean but adds complexity to the client implementation. Regardless of the chosen strategy, the most important aspect is consistency. Always provide a deprecation timeline for older versions and communicate changes clearly. By planning for versioning early, you show that you acknowledge the reality of evolving business requirements and are prepared to maintain backward compatibility, ensuring that your API remains reliable for users even as you introduce new features or change underlying data models.

// URI Versioning approach
// GET /api/v1/users/1
// GET /api/v2/users/1
// Using versioning ensures that consumers 
// can upgrade their endpoints at their own pace.

Key points

  • Always use HTTP methods that match the semantic intent of the requested operation.
  • Resource URIs should consist of plural nouns to represent clear, hierarchical objects.
  • Stateless communication is essential to enable horizontal scaling across multiple server instances.
  • Return standard HTTP status codes to clearly signal the result of an API request.
  • Never hide errors behind a 200 OK status code as it complicates client-side logic.
  • Versioning must be planned upfront to manage breaking changes without disrupting existing clients.
  • A clean API design separates resource identification from the underlying implementation details.
  • Consistent error structures allow for the implementation of robust, global client-side interceptors.

Common mistakes

  • Mistake: Using verbs in endpoint URLs. Why it's wrong: REST resources should be nouns. Fix: Use nouns like /users instead of /getUsers.
  • Mistake: Ignoring HTTP status codes for error handling. Why it's wrong: Returning 200 OK for every request makes client-side error handling impossible. Fix: Use appropriate codes like 400 for bad requests, 401 for unauthorized, and 404 for missing resources.
  • Mistake: Including sensitive data in GET request query parameters. Why it's wrong: Query parameters are logged in server logs and browser history. Fix: Pass sensitive information in the request body of a POST or PUT request.
  • Mistake: Creating monolithic endpoints that handle too many tasks. Why it's wrong: This breaks the resource-based philosophy and makes maintenance difficult. Fix: Keep endpoints focused on a single resource and follow standard CRUD mapping.
  • Mistake: Failing to implement pagination for collection resources. Why it's wrong: Returning thousands of items can crash the client and overwhelm the server. Fix: Always use parameters like 'limit' and 'offset' to constrain response sizes.

Interview questions

What are the core principles that define a RESTful API?

A RESTful API is defined by the architectural constraints of Representational State Transfer. The core principles include client-server separation, which ensures a clear boundary between UI and data storage, and statelessness, meaning every request from a client must contain all information necessary to process it. Additionally, it requires a uniform interface, often using HTTP methods like GET, POST, PUT, and DELETE to perform operations on resources identified by URIs. By adhering to these constraints, we ensure that APIs are scalable, modular, and maintainable across different distributed systems.

How do you choose between using PUT and PATCH for updating a resource?

The choice between PUT and PATCH depends on the intended semantics of the update operation. According to REST principles, PUT is defined as an idempotent operation used to replace the entire resource with the provided representation; if the client sends only partial data, the missing fields are essentially nulled or reset. Conversely, PATCH is used for partial updates, where the client sends only the specific fields that need to be modified. Choosing PATCH is safer for high-concurrency environments because it reduces bandwidth consumption and prevents accidental overwriting of resource fields that the client did not intend to touch.

What is the role of HTTP status codes in a RESTful architecture, and how should they be used?

HTTP status codes are the standardized mechanism for communicating the outcome of a request to the client. They should be used semantically: 200 OK for successful retrieval, 201 Created for successful resource creation, 400 Bad Request for client-side input errors, 401 Unauthorized for missing credentials, 403 Forbidden for insufficient permissions, and 404 Not Found when a resource does not exist. Using these codes correctly allows the client-side logic to react appropriately without needing to parse the response body to determine if the operation actually succeeded or failed.

Explain the importance of HATEOAS in REST API design.

HATEOAS, or Hypermedia as the Engine of Application State, is a constraint that allows a client to dynamically interact with an API through hypermedia links provided by the server. Instead of hardcoding URIs, the client receives links in the response, such as 'links': [{'rel': 'next', 'href': '/orders?page=2'}]. This decouples the client from the server’s internal URI structure, allowing the server to change its path mapping without breaking client functionality. It transforms the API into a truly discoverable and self-documenting system, which is essential for long-term API evolution.

Compare the use of URI-based filtering versus Query Parameters for searching resources.

URI-based filtering, such as '/users/active', is useful for permanent, named logical collections, whereas query parameters like '/users?status=active' are superior for dynamic filtering and complex searching. Query parameters are more scalable because they allow for combinations of filters, pagination, and sorting without creating a combinatorial explosion of URI endpoints. For example, '/users?status=active&sort=desc&limit=10' is significantly more flexible and maintainable than creating a unique path for every possible filter combination. Generally, query parameters should be the default choice for resource filtering.

How do you handle versioning in a REST API to ensure backward compatibility?

Versioning is critical because it allows the API to evolve without breaking existing clients. There are three common approaches: URI versioning ('/v1/resource'), Query Parameter versioning ('/resource?version=1'), and Custom Header versioning. URI versioning is the most explicit and popular, as it makes caching easier and improves readability. However, header versioning allows the resource URI to remain stable across iterations. Regardless of the choice, the primary goal is to ensure that when breaking changes are introduced, the older version remains available for a transition period, allowing clients to migrate at their own pace.

All REST API Design interview questions β†’

Check yourself

1. Which approach is most appropriate for a resource that requires partial updates to its properties?

  • A.Use a GET request with updated parameters
  • B.Use a PUT request to overwrite the entire resource
  • C.Use a PATCH request to send only the modified fields
  • D.Use a DELETE request to clear and recreate the resource
Show answer

C. Use a PATCH request to send only the modified fields
PATCH is designed for partial updates, making it efficient for modifying specific fields. PUT requires replacing the whole object, which is bandwidth-heavy. GET and DELETE are semantically incorrect for update operations.

2. When designing an API, which method should be used for idempotent creation operations?

  • A.POST
  • B.PUT
  • C.PATCH
  • D.HEAD
Show answer

B. PUT
PUT is idempotent; repeating the same PUT request multiple times results in the same state. POST is non-idempotent as it usually creates new instances. PATCH is generally non-idempotent depending on the implementation, and HEAD only retrieves headers.

3. A client requests a resource that no longer exists after having existed previously. Which HTTP status code is most suitable?

  • A.400 Bad Request
  • B.403 Forbidden
  • C.404 Not Found
  • D.410 Gone
Show answer

D. 410 Gone
410 Gone is the correct status for a resource that has been permanently removed. 404 is for resources that are not found (and potentially never existed). 400 and 403 signify different error conditions entirely.

4. What is the primary purpose of Hypermedia as the Engine of Application State (HATEOAS)?

  • A.To allow clients to discover API functionality dynamically via links in responses
  • B.To enable faster data transmission by compressing JSON payloads
  • C.To increase the security of the API by obfuscating endpoint names
  • D.To enforce a strict hierarchy in the database schema
Show answer

A. To allow clients to discover API functionality dynamically via links in responses
HATEOAS allows clients to interact with the API through links provided in responses, decoupling client knowledge from server architecture. It has nothing to do with compression, security, or database schemas.

5. Why is it important to use standard HTTP methods instead of creating custom methods?

  • A.Standard methods are the only ones supported by databases
  • B.It ensures interoperability with standard tools, caches, and security frameworks
  • C.Standard methods are faster to execute than custom ones
  • D.Custom methods cannot be documented in API specifications
Show answer

B. It ensures interoperability with standard tools, caches, and security frameworks
Standard methods (GET, POST, etc.) ensure that caches, proxies, and security software handle the traffic correctly. Custom methods break this contract. Standard methods have no inherent speed advantage, and documentation can technically describe anything.

Take the full REST API Design quiz β†’

← PreviousLoad Testing APIsNext β†’REST vs GraphQL vs gRPC

REST API Design

24 lessons, free to read.

All lessons β†’

Track your progress

Sign in to mark lessons done, score quizzes and keep notes.

Open in the app