What is an API?
An API (Application Programming Interface) is a contract between a client and a server. It allows one system to request data or actions without exposing how the backend works.
Example: Uber calls the Google Maps API to show routes, distances, and travel time. Uber does not build the map service itself.
API vs UI testing
UI testing depends on pages, buttons, and browser rendering. API testing calls the backend directly, making it faster and less brittle.
- UI failure: broken button, layout change, or CSS issue
- API failure: incorrect response, wrong status code, or data contract mismatch
Types of APIs
REST
Common web API style using HTTP and JSON. REST APIs are stateless and easy to automate.
SOAP
Legacy XML-based APIs with strict message formats. Often found in banking and enterprise systems.
GraphQL
Modern API style where clients request only the fields they need, reducing over-fetching.
API contract example
An API contract is the documented request and response shape. Tests validate that the contract remains stable.
GET /users/1
Response:
{
"id": 1,
"name": "Wasim"
}
Focus on the request input, expected status code, and response body rather than server internals.
Local API notes
This page is based on your local API training notes for clear, self-contained content.
Open local API notes