REST Basics Interview Questions and Answers

Master REST API fundamentals with 15 interview questions and detailed answers covering concepts, architecture, internal working, production examples, Spring Boot implementation, common mistakes, and interview follow-up questions.


REST Basics Interview Questions and Answers

Introduction

REST (Representational State Transfer) is the most widely used architectural style for building modern web APIs. Almost every Java Spring Boot, .NET, Node.js, Python, Go, and cloud-native application exposes REST APIs to communicate with frontend applications, mobile apps, partner systems, and microservices.

For Java developers, REST is one of the most frequently asked interview topics in companies like Amazon, Google, Microsoft, IBM, Oracle, Salesforce, Walmart, Visa, PayPal, JP Morgan Chase, Capital One, and many more.

In this guide, you'll learn the 15 most important REST interview questions with production-oriented explanations, Spring Boot examples, common mistakes, and interview follow-up questions.


1. What is REST?

Short Answer

REST (Representational State Transfer) is an architectural style for designing distributed web services. It uses HTTP protocols and treats everything as a resource identified by a unique URI.


Detailed Explanation

REST was introduced by Roy Fielding in his Ph.D. dissertation in 2000.

REST is not a protocol.

REST is not a programming language.

REST is an architectural style that defines principles for building scalable, maintainable, and loosely coupled APIs.

REST APIs usually exchange data using:

  • JSON (Most common)
  • XML
  • Plain Text
  • HTML
  • Binary data

Internal Working

sequenceDiagram
    participant C as Client
    participant API as REST API
    participant BL as Business Logic
    participant DB as Database
    C->>API: GET /employees/101
    API->>BL: Process Request
    BL->>DB: Query Data
    DB->>BL: Return Record
    BL->>API: Build Response
    API->>C: HTTP 200 (JSON)

Production Example

Amazon Product API

GET /products/12345

Response

{
  "id":12345,
  "name":"Laptop",
  "price":899
}

Spring Boot Example

@RestController
@RequestMapping("/employees")
public class EmployeeController {

    @GetMapping("/{id}")
    public Employee getEmployee(@PathVariable Long id){
        return employeeService.findById(id);
    }

}

Common Mistakes

❌ REST is a protocol.

❌ REST only supports JSON.

❌ REST requires HTTP POST.


Best Practices

  • Use nouns instead of verbs
  • Use HTTP correctly
  • Return meaningful status codes
  • Keep APIs stateless

Interview Follow-up

  • Who invented REST?
  • Is REST a protocol?
  • Why is REST scalable?

2. Why was REST introduced?

Short Answer

REST was introduced to solve scalability, interoperability, simplicity, and maintainability problems of distributed web systems.


Detailed Explanation

Before REST became popular, applications mainly relied on SOAP-based web services.

Problems included:

  • Heavy XML payloads
  • Complex standards
  • Tight coupling
  • Slower communication

REST simplified communication using HTTP and lightweight data formats.


Production Example

Instead of

SOAP Envelope

Modern applications use

GET /customers/100

which returns JSON.


Common Mistakes

Thinking REST replaced SOAP.

Reality:

SOAP still exists in banking, healthcare, and enterprise integrations.


Interview Follow-up

Why did most companies migrate from SOAP to REST?


3. What is a Resource in REST?

Short Answer

A resource is any object or information exposed through a REST API.


Examples

  • Employee
  • Customer
  • Order
  • Product
  • Invoice

Each resource has a unique URI.

/employees

/orders

/products

Internal Working

Database Record
      │
      ▼
Employee Object
      │
      ▼
REST Resource
      │
      ▼
JSON Response

Spring Boot Example

@GetMapping("/orders/{id}")
public Order getOrder(@PathVariable Long id){
    return service.find(id);
}

Common Mistakes

Using actions instead of resources.

Bad

/getEmployee

Good

/employees/{id}

4. What is Resource Representation?

Short Answer

The resource itself stays on the server. The client receives only a representation of that resource.


Example

Resource

Employee

Representation

{
  "id":101,
  "name":"John"
}

or

<Employee>
   <id>101</id>
</Employee>

Production Use

A mobile application may request JSON.

A legacy system may request XML.

The underlying resource remains the same.


Interview Follow-up

Can one resource have multiple representations?

Answer: Yes.


5. How does REST work internally?

Short Answer

REST receives an HTTP request, maps it to a resource, executes business logic, accesses the database, and returns an HTTP response.


Internal Flow

Client

↓

HTTP Request

↓

Dispatcher

↓

Controller

↓

Service

↓

Repository

↓

Database

↓

JSON Response

Spring Boot Example

@GetMapping("/{id}")
public Employee find(@PathVariable Long id){
    return employeeService.find(id);
}

Production Example

Banking Application

GET /accounts/123

Fetch account

Return JSON


6. Why is HTTP important for REST?

Short Answer

REST uses HTTP as the communication protocol.


Common HTTP Methods

Method Purpose
GET Read
POST Create
PUT Replace
PATCH Update
DELETE Remove

Production Example

GET /customers

POST /customers

PUT /customers/10

DELETE /customers/10

Interview Follow-up

Can REST work without HTTP?

Yes.

Although HTTP is most common, REST principles can be applied over other protocols. However, nearly all production REST APIs use HTTP.


7. Is REST a Protocol?

Short Answer

No.

REST is an architectural style.

HTTP is the protocol.


Comparison

REST HTTP
Architecture Protocol
Guidelines Communication
Defines API Design Transfers Data

Common Interview Trap

"REST uses HTTP"

does NOT mean

"REST is HTTP"


8. REST API vs Web Service

Short Answer

Every REST API is a web service, but not every web service is REST.


Comparison

Feature REST SOAP
Lightweight
JSON Limited
XML Optional Required
Speed Faster Slower
Scalability Better Moderate

Production Example

Most microservices today expose REST APIs.

Legacy banking systems often still use SOAP.


9. Can REST APIs return XML?

Short Answer

Yes.

REST is independent of the response format.


Supported Formats

  • JSON
  • XML
  • CSV
  • HTML
  • Binary
  • PDF

Example

Accept: application/xml

Server

<Employee>
    <id>10</id>
</Employee>

10. What are some real-world examples of REST APIs?

Examples include:

  • Amazon Product API
  • Google Maps API
  • GitHub REST API
  • Stripe Payments API
  • PayPal API
  • Spotify API
  • Twilio API
  • Salesforce API

These APIs expose resources through predictable HTTP endpoints.


11. How are REST APIs used in production?

Typical enterprise architecture:

React

↓

API Gateway

↓

Spring Boot REST API

↓

Service Layer

↓

Database

↓

Kafka

↓

Other Microservices

Production Characteristics

  • Stateless
  • Load balanced
  • Secured using OAuth2/JWT
  • Monitored using Prometheus/Grafana
  • Logged using ELK or Splunk
  • Documented using OpenAPI/Swagger

12. What are common misconceptions about REST?

REST always uses JSON

❌ False

REST supports multiple representations.


REST equals HTTP

❌ False

REST commonly uses HTTP but is an architectural style.


REST APIs are always stateless

The server should not store client session state between requests.


13. What are the advantages and disadvantages of REST?

Advantages

  • Lightweight
  • Fast
  • Easy to understand
  • Platform independent
  • Cacheable
  • Scalable
  • Supports multiple clients
  • Ideal for cloud-native applications

Disadvantages

  • No strict contract by default
  • Multiple API versioning strategies
  • Over-fetching and under-fetching can occur
  • Less suitable for long-running transactions

14. Where is REST commonly used?

REST is widely used in:

  • Banking applications
  • Insurance platforms
  • E-commerce
  • Healthcare systems
  • Travel booking
  • Mobile applications
  • IoT
  • Cloud-native microservices
  • SaaS products

15. Design a REST API for an Employee Management System

Resources

/employees
/departments
/projects

Endpoints

GET    /employees
GET    /employees/{id}

POST   /employees

PUT    /employees/{id}

PATCH  /employees/{id}

DELETE /employees/{id}

Sample Response

{
  "id":101,
  "name":"John",
  "department":"Engineering",
  "salary":85000
}

Interview Tips

When asked to design a REST API:

  1. Identify resources (nouns).
  2. Use appropriate HTTP methods.
  3. Return meaningful HTTP status codes.
  4. Keep APIs stateless.
  5. Use consistent URI naming.
  6. Support pagination and filtering where appropriate.
  7. Secure APIs with authentication and authorization.
  8. Document APIs using OpenAPI/Swagger.

Key Takeaways

  • REST is an architectural style, not a protocol.
  • Everything in REST is treated as a resource identified by a URI.
  • HTTP is the most common protocol used by REST APIs.
  • Resources can have multiple representations such as JSON or XML.
  • REST promotes stateless, scalable, and loosely coupled systems.
  • Proper use of HTTP methods and status codes is essential for production-ready APIs.
  • Most modern microservices and cloud-native applications expose REST APIs.
  • Understanding REST fundamentals is critical for Java, Spring Boot, and backend interviews.