ASP.NET Core Web API Interview Question #3

What is a resource in a REST API?

Web API & REST Fundamentals, Controllers, HTTP Methods & Status Codes Junior Beginner

Quick Interview Answer

A resource is a concept or entity exposed by an API, such as a product, customer, order, or invoice. A resource is normally identified by a URI and represented in a format such as JSON.

Detailed Explanation

A resource is a concept or entity exposed by an API, such as a product, customer, order, or invoice. A resource is normally identified by a URI and represented in a format such as JSON.

API routes should generally describe resources with nouns rather than implementation-oriented action names. The HTTP method communicates the operation being performed on that resource.

Code Example

GET /api/products/42

{
  "id": 42,
  "name": "Wireless Mouse",
  "price": 29.99
}