Tool for HR, Hiring Managers, and the Leadership Team

REST API Interview Questions

Here are REST API Interview Questions & Answers explained in a clear, interview-focused way with examples (especially .NET).

REST API Interview Questions (With Answers)

1. What is REST API?

REST (Representational State Transfer) is an architectural style used to build web services that communicate over HTTP.

A REST API uses:

  • HTTP Methods (GET, POST, PUT, DELETE)

  • URLs (Endpoints)

  • Stateless communication

  • JSON/XML responses

Example

GET /api/users/1

Response

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

2. What are HTTP Methods in REST?

Method Purpose Example
GET Get data Get users
POST Create data Create user
PUT Update entire record Update user
PATCH Partial update Update email
DELETE Delete record Delete user

Example (.NET)

[HttpGet]
public IActionResult GetUsers()
{
    return Ok(users);
}

[HttpPost]
public IActionResult CreateUser(User user)
{
    return Ok(user);
}

3. What is Stateless in REST?

Stateless means server does not store client state.

Each request must contain all information.

Example

❌ Bad (Stateful)

Login → Save session → Use session

✅ Good (Stateless)

Login → Send token → Use token every request

4. What is RESTful API?

RESTful API follows REST principles:

  • Stateless

  • Uses HTTP methods

  • Uses URLs for resources

  • Returns JSON/XML

Example:

GET /api/products
POST /api/products
DELETE /api/products/1

5. What is Resource in REST?

Resource = Object or Data

Examples:

/users
/products
/orders

Each resource has:

/users/1

6. What is Idempotent Method?

Idempotent = Same result even if called multiple times

Method Idempotent
GET Yes
PUT Yes
DELETE Yes
POST No

Example

DELETE /users/1
DELETE /users/1

Still user deleted → Idempotent

7. What is Status Code?

HTTP response codes:

Code Meaning
200 OK
201 Created
204 No Content
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
500 Server Error

Example

return NotFound();
return BadRequest();
return Ok(data);

8. What is PUT vs PATCH?

PUT

Update entire object

PUT /users/1
{
 "name":"John",
 "email":"john@gmail.com"
}

PATCH

Update partial object

PATCH /users/1
{
 "email":"john@gmail.com"
}

9. What is REST API Endpoint?

Endpoint = URL where API is accessed

Examples:

GET /api/users
GET /api/users/1
POST /api/users

10. What is Query Parameter?

Used for filtering

Example:

GET /users?department=HR
GET /products?page=1

.NET Example:

[HttpGet]
public IActionResult GetUsers(string department)
{
    return Ok();
}

11. What is Path Parameter?

Used to identify specific resource

GET /users/1

.NET Example:

[HttpGet("{id}")]
public IActionResult GetUser(int id)
{
    return Ok();
}

12. What is Content Negotiation?

Client tells server what format it wants

Accept: application/json
Accept: application/xml

Server responds accordingly.

13. What is Versioning in REST API?

Used when API changes

URL Versioning

/api/v1/users
/api/v2/users

Header Versioning

Accept: application/vnd.company.v1+json

14. What is Pagination?

Used to load data in chunks

Example:

GET /users?page=1&pageSize=10

15. What is HATEOAS?

API returns links for next actions

Example:

{
 "id":1,
 "name":"John",
 "links":[
  {
   "rel":"orders",
   "href":"/users/1/orders"
  }
 ]
}

(Not commonly used in real-world apps but asked in interviews)

16. What is Authentication in REST API?

Common methods:

  • JWT Token

  • OAuth

  • API Key

  • Basic Authentication

Example:

Authorization: Bearer token

17. What is REST vs SOAP?

REST SOAP
Lightweight Heavy
JSON XML
Fast Slow
Easy Complex

REST is more commonly used.

18. What is Caching in REST?

Server can cache response

Example:

Cache-Control: max-age=3600

Improves performance.

19. What is 401 vs 403?

Code Meaning
401 Not authenticated
403 Not authorized

Example:

  • 401 → No login

  • 403 → Logged in but no permission

20. What is Best Practice for REST URLs?

Good:

/users
/users/1
/users/1/orders

Bad:

/getUsers
/createUser
/deleteUser

Use nouns not verbs

Tricky REST Interview Questions

1. Can GET request have body?

Technically yes, but not recommended.

2. Is REST protocol?

No.
REST is architectural style, not protocol.

3. Can REST use only JSON?

No.
REST can use:

  • JSON

  • XML

  • Text

  • HTML

4. Is REST always HTTP?

Mostly yes, but technically REST can use other protocols.

Real Interview Questions

  1. What is REST?

  2. What is Stateless?

  3. PUT vs PATCH?

  4. Idempotent methods?

  5. REST vs SOAP?

  6. What is HATEOAS?

  7. What is versioning?

  8. What is pagination?

  9. What are status codes?

  10. What is resource?