Testing APIs (Application Programming Interfaces) to verify they work correctly, reliably, securely, and perform well.
APIs are the backbone of modern applications. Mobile apps use APIs to get data from backend servers. Frontend communicates with backend via APIs. Microservices communicate via APIs. Testing APIs is critical but often overlooked. API bugs are invisible to users (no UI), but they break functionality completely.
| Method | Purpose | Example | Should Return |
|---|---|---|---|
| GET | Retrieve data (read-only, safe, idempotent) | GET /api/users/123 retrieves user with ID 123 | 200 OK with user data in response body |
| POST | Create new data (creates resource) | POST /api/users with body {name: 'John'} creates new user | 201 Created with new user data |
| PUT | Update entire resource (replace) | PUT /api/users/123 with body {name: 'Jane'} replaces user data | 200 OK with updated data |
| PATCH | Partially update resource (modify specific fields) | PATCH /api/users/123 with body {email: 'john@new.com'} updates only email | 200 OK with updated data |
| DELETE | Delete resource | DELETE /api/users/123 deletes user with ID 123 | 204 No Content or 200 OK |
| Code | Meaning | Example |
|---|---|---|
| 200 OK | Request successful | GET /api/users returns 200 with user list |
| 201 Created | Resource created successfully | POST /api/users returns 201 with new user |
| 204 No Content | Success but no data to return | DELETE /api/users/123 returns 204 |
| 400 Bad Request | Invalid request (client error) | POST /api/users without required name field |
| 401 Unauthorized | Authentication required | API request without login token |
| 403 Forbidden | Authenticated but not authorized | User tries to access admin endpoint |
| 404 Not Found | Resource doesn't exist | GET /api/users/999 when user doesn't exist |
| 500 Server Error | Internal server error | Unexpected backend crash |
| 503 Unavailable | Service temporarily down | Server under maintenance |
| Component | Description | Example |
|---|---|---|
| URL/Endpoint | /api/users or /api/users/123 | Points to the resource being accessed |
| HTTP Method | GET, POST, PUT, DELETE | Specifies the action |
| Headers | Content-Type, Authorization, etc. | Content-Type: application/json tells server data is JSON |
| Body/Payload | Data being sent (for POST, PUT, PATCH) | {name: 'John', email: 'john@example.com'} |
| Query Parameters | ?page=1&limit=10 | Filters or pagination parameters |
Functionality Testing
Boundary/Edge Case Testing
Security Testing
Performance Testing
Data Integrity Testing
POST /api/orders/checkout
Valid Checkout
POST /api/orders/checkout {userId: 123, items: [{productId: 1, qty: 2}], paymentMethod: 'card'}
201 Created {orderId: 999, totalAmount: 100, status: 'confirmed'}
Order created, correct total calculated, status is confirmed
Invalid User
POST /api/orders/checkout {userId: 99999, items: [...]}
400 Bad Request {error: 'User not found'}
Returns 400, not 500. Error message is clear.
Insufficient Stock
POST /api/orders/checkout {userId: 123, items: [{productId: 1, qty: 1000}]}
409 Conflict {error: 'Only 50 items in stock'}
Returns 409, not silent failure. User knows why order failed.
| Tool | Use | Features |
|---|---|---|
| Postman | Manual and automated API testing, collection sharing | Easy UI, good for beginners |
| Rest Assured | Java-based API testing in CI/CD pipelines | Java syntax, integrates with TestNG |
| SoapUI | SOAP and REST API testing | Load testing, security scanning |
| Insomnia | API testing with good UX | Team collaboration, environment management |
| JMeter | Performance/load testing for APIs | Simulate thousands of concurrent users |
| Swagger/OpenAPI | API documentation and auto-generated tests | Contract-driven testing |
Your user API has GET /api/users/123. Without authentication, this returns all user data including passwords. What would you do?
🔗 API testing = Testing data flow without UI. Master this to advance your QA career. Postman is your best friend.
API testing is modern, essential skill. Interviewers value candidates who understand APIs deeply.