API testing validates that application programming interfaces meet functionality, reliability, performance, and security requirements.
API Testing
The process of verifying that APIs work correctly, securely, and perform well.
Types of API Testing
- Functional Testing: Verify correct behavior and responses
- Integration Testing: Test how APIs work together
- Load Testing: Measure performance under high traffic
- Security Testing: Check for vulnerabilities
What to Test
- HTTP status codes (200, 400, 401, 404, 500)
- Response body structure and data types
- Headers (Content-Type, Authorization)
- Response time and latency
- Error messages and handling
Code Examples
Jest API Test
test("GET /users returns 200", async () => {
const res = await fetch("/api/users");
expect(res.status).toBe(200);
});Related Terms
Mock Server
A fake server that simulates API responses for testing and development purposes.
Read more
REST API
An architectural style for building web APIs using HTTP methods and stateless communication.
Read more
WebSocket
A protocol enabling full-duplex, real-time communication between client and server.
Read more
Latency
The time delay between a request being sent and a response being received.
Read more