</>

Technology

Rest Assured

Difficulty

Beginner

Interview Question

Explain the major components of a REST API

Answer

4 Components of a REST API

1. API Client

The software or application that initiates requests to the API server to retrieve or manipulate data.

  • Acts as intermediary between the end-user and the API server
  • Responsible for sending properly formatted requests and handling responses

Example: A mobile app that displays weather information. The app sends a request to the weather API server to fetch current weather data.

2. API Request

A message sent by the client to the API server, indicating the action it wants to perform.

Contains:

  • Endpoint (URL) — specific API resource path
  • HTTP Method — GET, POST, PUT, DELETE, etc.
  • Headers — metadata like Content-Type, Authorization
  • Body — data payload (for POST/PUT requests)

Example: GET https://api.weather.com/current-weather — fetches weather data for a location.

3. API Server

A software application that receives requests, processes them, interacts with the database or other services, and generates a response.

  • Acts as the gateway to the backend system
  • Provides access to the requested resources

Example: The weather API server receives the GET request, queries its database, and generates a response with temperature, humidity, and weather conditions.

4. API Response

The message sent by the server back to the client in reply to the API request.

Contains:

  • Data requested by the client (JSON/XML)
  • Status codes — 200, 201, 404, 500, etc.
  • Headers — Content-Type, Cache-Control, etc.

Example: After processing the GET request, the weather server sends back { "temperature": 25, "humidity": 65, "condition": "Sunny" }.

Follow AutomateQA

Related Topics