Back to blog Backend Interview

Restful API mostly asked interview questions

13 min readBackend Interview

REST & HTTP Fundamentals

1. What is REST and what are its architectural principles?

REST (Representational State Transfer) is an architectural style for designing scalable, stateless web services that communicate over HTTP.

Key REST principles:

  • Code on demand (optional)
  • Client–Server separation
  • Stateless communication
  • Uniform interface
  • Cacheability
  • Layered system

2. What are RESTful web services?

3. How does REST differ from SOAP?

4. What are the main HTTP methods used in REST?

5. What is a resource in RESTful APIs?

6. Explain statelessness in REST APIs.

7. What is a URI and how is it used in REST?

8. What does CRUD stand for and how does it map to REST methods?

9. What are safe and idempotent HTTP methods?

10. What are common HTTP status codes used in RESTful APIs and their meanings?

REST Architecture & Concepts

1. What are REST constraints (uniform interface, cache-ability, layer system)?

Uniform Interface: Standard way to interact with resources using HTTP methods, URIs, headers, and status codes, improves simplicity and interoperability.

Cache-ability: Responses must define whether they are cacheable to improve performance and reduce server load.

Layered System: Client does not know whether it is communicating directly with the server or an intermediary (proxy, gateway), improving scalability and security.

2. What is HATEOAS? Explain its importance.

3. What is idempotency and why is it important?

4. What is content negotiation?

5. How is versioning handled in REST APIs?

6. What is caching and how can it be implemented in REST?

7. Explain the difference between PUT vs PATCH.

8. What is pagination and how do you implement it?

9. What are ETags and how do they help with caching?

10. What is API version depreciation strategy?

Design & Best Practices

1. What are REST API design best practices?

Key best practices include:

  • Use nouns for resources (/users, /orders)
  • Follow HTTP methods semantics correctly (GET, POST, PUT, DELETE)
  • Return proper HTTP status codes
  • Make APIs stateless
  • Support pagination, filtering, sorting
  • Use versioning for breaking changes
  • Provide consistent error responses
  • Secure APIs using OAuth2 / JWT
  • Document APIs clearly

These practices improve maintainability, scalability, and developer experience.

2. How do you choose resource naming conventions?

3. What is API documentation and how is it maintained?

4. What are common patterns for API error responses?

5. How do you handle API deprecation?

6. How does an API gateway work? (high-level)

7. What is API throttling?

8. How do you design for backward compatibility?

Error Handling & Testing

1. How do you implement error handling in RESTful APIs?

Error handling in RESTful APIs is implemented by returning appropriate HTTP status codes along with a clear and consistent error response body, and by centralizing exception handling.

Key steps to implement error handling

  1. Use correct HTTP status codes
    • 400 Bad Request – Invalid input / validation error
    • 401 Unauthorized – Authentication required
    • 403 Forbidden – Access denied
    • 404 Not Found – Resource not found
    • 500 Internal Server Error – Server failure
  2. Define a standard error response structure
    Return a predictable JSON format so clients can easily parse errors:
  1. Centralize exception handling
    Handle all exceptions in one place instead of per controller.
    • In Spring Boot, use @ControllerAdvice with @ExceptionHandler
  2. Handle validation errors explicitly
    Return meaningful messages for field-level validation failures.
  3. Avoid exposing internal details
    Do not leak stack traces or sensitive system information in responses.
  4. Log errors properly
    Log technical details on the server while returning user-friendly messages to clients.

2. How do you test REST APIs? (tools & methods)

3. How do you use Postman/Swagger for testing and documentation?

4. What are mock servers and how are they used?

5. What is load testing in the context of REST APIs?

Real-World & Scenario Questions

1. Describe how you would design a REST API for an e-commerce order system.

2. How would you handle file uploads/downloads via REST API?

3. How do you manage REST API version upgrades in production?

4. How would you handle large JSON responses efficiently?

5. How do you implement filtering & sorting in an API?

6. What metrics would you track to monitor API health?

InterviewExpert.org

Writing about interviews, stacks, and getting hired.

Leave a comment