</>

Technology

Rest Assured

Difficulty

Beginner

Interview Question

What is an API and how does it work?

Answer

What is an API?

API stands for Application Programming Interface. It acts as a messenger — like a waiter in a restaurant — that takes your request, communicates it to the system (kitchen), and delivers the response back to you (food).

Real-Life Example

When you search for flights on an airline website, you interact with the airline's database through their API. If you use an online travel service like Kayak or Expedia, that service calls the airline's API to aggregate information from multiple databases.

How APIs Work

  1. Client sends a request (e.g., "Get all users")
  2. API receives the request and routes it to the server
  3. Server processes the request and queries the database
  4. API returns the response (data, status code) to the client

Key Benefits

  • Separation of concerns — frontend and backend are decoupled
  • Reusability — one API can serve web, mobile, and third-party apps
  • Security — only exposes what's needed, hides internal logic
  • Standardization — REST, SOAP, GraphQL are common standards

API vs Web Service

FeatureAPIWeb Service
Network requiredNot alwaysAlways
CommunicationVarious formatsSOAP, REST, XML-RPC
ScopeBroaderSubset of API

Follow AutomateQA

Related Topics