WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

System Design · Intermediate · question 23 of 100

What are the four main components of a RESTful API?

📕 Buy this interview preparation book: 100 System Design questions & answers — PDF + EPUB for $5

RESTful APIs (Representational State Transfer APIs) are a common way to create web services that can be accessed over HTTP. RESTful APIs are designed to be simple and flexible, allowing developers to easily create and consume web services. There are four main components of a RESTful API, which are:

Resource: A resource is a piece of data that can be accessed or manipulated using the API. In RESTful API design, each resource is identified by a unique URL (Uniform Resource Locator). For example, a resource for a user profile might be identified by the URL "/users/user_id".

Verb: A verb is an HTTP method that is used to interact with a resource. The most commonly used HTTP verbs in RESTful API design are GET, POST, PUT, and DELETE. GET is used to retrieve data, POST is used to create new data, PUT is used to update existing data, and DELETE is used to delete data.

Representation: A representation is the format in which a resource is returned by the API. The most commonly used representations in RESTful API design are JSON (JavaScript Object Notation) and XML (Extensible Markup Language).

Hypermedia: Hypermedia is a set of links that are included in the representation of a resource. These links can be used to navigate between related resources, allowing the API to provide a rich and dynamic user experience. Hypermedia links are often expressed using the HATEOAS (Hypermedia as the Engine of Application State) principle.

Here is an example to illustrate the four main components of a RESTful API:

Suppose a company operates an e-commerce website that allows users to browse and purchase products. The website uses a RESTful API to provide access to product data and user information.

When a user visits the website, the API is used to retrieve product data, such as product descriptions and prices, and user information, such as account details and purchase history. The API uses the following four main components to provide access to this data:

Resource: The resources in the API include products, users, and orders. Each resource is identified by a unique URL, such as "/products/product_id" or "/users/user_id".

Verb: The API uses HTTP verbs to interact with resources. For example, a GET request might be used to retrieve product data, a POST request might be used to create a new order, and a PUT request might be used to update user account information.

Representation: The API returns data in JSON format, which is a common format for web services. The JSON representation of a product might include fields such as product name, price, and description.

Hypermedia: The API includes hypermedia links that allow users to navigate between related resources. For example, a product representation might include links to related products, and a user representation might include links to order history or account settings.

In summary, the four main components of a RESTful API are resource, verb, representation, and hypermedia. These components provide a simple and flexible way to create web services that can be accessed over HTTP, and are commonly used in modern web development.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic System Design interview — then scores it.
📞 Practice System Design — free 15 min
📕 Buy this interview preparation book: 100 System Design questions & answers — PDF + EPUB for $5

All 100 System Design questions · All topics