Introduction to APIs
What is an API?
An API (Application Programming Interface) is a set of rules that allows different software systems to communicate with each other.
Think of it like a waiter in a restaurant:
● You (client) place an order
● The waiter (API) sends it to the kitchen (server)
● The kitchen prepares food and sends it back via the waiter
Example:
When you use a mobile app to check weather:
● The app sends a request to a weather API
● The API returns data (temperature, humidity, etc.)
Types of APIs
1. REST API (Most Common)
● Uses HTTP protocol
● Data format: JSON
● Lightweight and fast
● Stateless (no memory of previous requests)
Example:
GET /users/1
2. SOAP API
● Uses XML format
● Strict standards and security
● Heavier than REST
Common in banking and enterprise systems
3. GraphQL API
● Client decides what data it wants
● Avoids over-fetching or under-fetching
● Flexible and efficient
Example:
Instead of getting full user data, you request only:
name, email
API vs Web Services
Feature API Web Service --------------------------------------------------------------------- Definition Interface for communication API over web (HTTP) Protocol Any (HTTP, TCP, etc.) Only HTTP Scope Broader Subset of API Key Point: All web services are APIs, but not all APIs are web services.
API vs UI Testing
Feature API Testing UI Testing ------------------------------------ Layer Backend Frontend Speed Fast Slow Stability More stable Breaks easily Focus Data & logic User interface Example: API testing checks if login API returns success UI testing checks if login button works visually
Key:
● API = communication bridge between systems
● REST is most widely used
● API testing focuses on backend logic
● APIs power almost every modern application