Introduction – Why API Testing Is Important in Interviews
APIs are the backbone of modern applications—connecting web, mobile, backend services, and third-party systems. Because UI layers change frequently, interviewers rely on top api testing interview questions to assess whether candidates truly understand backend behavior, data validation, and integrations.
In interviews, recruiters evaluate whether you can:
- Validate business logic without UI
- Understand REST/SOAP fundamentals
- Check status codes, headers, schemas
- Use tools like Postman, SoapUI, Rest Assured, Python
- Explain real-time issues and debugging steps
This guide is designed for freshers to experienced testers, with clear answers, examples, and scenarios.
What Is API Testing? (Clear & Simple)
API testing verifies that an API:
- Accepts valid requests
- Enforces business rules
- Returns correct responses and status codes
- Handles errors, security, and edge cases
Example:
For a login API:
- Valid credentials → 200 OK + token
- Invalid credentials → 401 Unauthorized
- Missing fields → 400 Bad Request
REST vs SOAP vs GraphQL (Interview Comparison)
| Feature | REST | SOAP | GraphQL |
| Transport | HTTP | HTTP/SMTP | HTTP |
| Payload | JSON/XML | XML | JSON |
| Contract | Optional | WSDL | Schema |
| Performance | Fast | Slower | Optimized |
| Usage | Most modern apps | Banking/Legacy | Modern microservices |
Top API Testing Interview Questions & Answers (100+)
Section A: Fundamentals (Q1–Q20)
- What is an API?
A contract that lets systems communicate via requests/responses. - What is API testing?
Validating endpoints, payloads, headers, status codes, and business rules. - API testing vs UI testing?
API tests backend logic; UI tests presentation. - HTTP methods?
GET, POST, PUT, PATCH, DELETE. - PUT vs PATCH?
PUT replaces full resource; PATCH updates part. - Endpoint?
A URL representing a resource/action. - Request payload?
Data sent to the API. - Response body?
Data returned by the API. - Statelessness?
Each request is independent. - Idempotency?
Same request → same outcome. - Authentication vs Authorization?
Identity vs permission. - Common auth types?
Bearer token, API key, OAuth. - JWT?
Signed token with claims. - API versioning?
Managing changes via /v1, /v2. - Schema?
Defines structure and types. - Negative testing?
Invalid inputs/flows. - Boundary testing?
Min/max values. - Regression testing?
Re-test after changes. - Smoke testing?
Basic health checks. - API chaining?
Use one response in another request.
Section B: Status Codes & Validations (Q21–Q35)
| Code | Meaning | Use |
| 200 | OK | Success |
| 201 | Created | Resource created |
| 204 | No Content | Success w/o body |
| 400 | Bad Request | Invalid input |
| 401 | Unauthorized | Invalid auth |
| 403 | Forbidden | No permission |
| 404 | Not Found | Wrong endpoint |
| 409 | Conflict | Duplicate |
| 422 | Unprocessable | Rule violation |
| 500 | Server Error | Backend failure |
Is 200 enough?
No—validate data and rules.- Header validation?
Check Authorization, Content-Type, caching. - Schema validation?
Ensure structure/types match spec. - Response time validation?
Meet SLA limits. - Pagination testing?
Pages, counts, boundaries. - Filtering/sorting?
Query params behavior. - Rate limiting?
Expect 429 after threshold. - Caching?
Headers and freshness. - Concurrency?
Parallel requests correctness. - Rollback?
No partial data on failure. - Data consistency?
Same data across systems. - Error messages?
Clear and actionable. - Default values?
Applied when omitted. - Enums?
Reject unsupported values. - Localization?
Locale/language responses.
Section C: Functional Scenarios (Q36–Q60)
- Test POST create?
201, body fields, DB side-effects. - Test GET read?
200, fields, filters. - Test PUT/PATCH update?
Changed vs unchanged fields. - Test DELETE?
204 and resource removal. - Auth failures?
401/403 for invalid/missing token. - Idempotency check?
Repeat PUT. - Calculation rules?
Totals, tax, discounts. - Date rules?
Past/future constraints. - File upload APIs?
Type/size validation. - Webhooks?
Trigger and verify callbacks. - Dependencies?
Graceful failure handling. - Retries?
Transient failures behavior. - Search APIs?
Exact vs partial matches. - Bulk operations?
Partial success handling. - Null handling?
Required vs optional fields. - Backward compatibility?
Older clients unaffected. - ETags?
Optimistic locking. - Sorting stability?
Deterministic order. - Timezones?
Correct offsets. - Precision/rounding?
Financial accuracy. - Throttling headers?
Remaining quota info. - Cache invalidation?
Updates clear cache. - Soft delete?
Visibility vs removal. - Feature flags?
Conditional behavior. - Observability?
Trace IDs/log correlation.
Status Codes + API Validation Example
Request
POST /api/orders
Content-Type: application/json
Authorization: Bearer <token>
{
“productId”: 501,
“quantity”: 2,
“coupon”: “SAVE10”
}
Response
{
“orderId”: 9001,
“subtotal”: 200,
“discount”: 20,
“tax”: 18,
“total”: 198,
“status”: “CREATED”
}
Validations
- Status 201
- total = subtotal – discount + tax
- quantity > 0
- Fields exist & types correct
Tooling & Automation Snippets
Postman Tests (JavaScript)
pm.test(“201 Created”, () => {
pm.response.to.have.status(201);
});
pm.test(“Total calculation”, () => {
const r = pm.response.json();
pm.expect(r.total).to.eql(r.subtotal – r.discount + r.tax);
});
Rest Assured (Java)
given()
.contentType(“application/json”)
.body(payload)
.when()
.post(“/orders”)
.then()
.statusCode(201)
.body(“status”, equalTo(“CREATED”));
Python (requests)
import requests
res = requests.post(url, json=payload, headers=headers)
assert res.status_code == 201
data = res.json()
assert data[“total”] == data[“subtotal”] – data[“discount”] + data[“tax”]
Scenario-Based Practical Q&A (15)
- 200 OK but wrong total—what validations add?
- Coupon applied twice—what rule missed?
- Order created without auth—what defect?
- PATCH updates all fields—issue?
- DELETE returns 200 with body—acceptable?
- Pagination duplicates—cause?
- Overselling stock—how test concurrency?
- Expired token still works—defect?
- 422 vs 400—when each?
- Non-deterministic responses—why?
- Timezone bugs—how catch?
- Search ignores filters—where look?
- Retry causes duplicates—prevention?
- Webhook not fired—verification?
- Schema changed silently—impact?
How Interviewers Evaluate Your Answer
They look for:
- Clear functional reasoning
- Validation beyond status codes
- Real examples and edge cases
- Tool usage and assertions
- Calm debugging approach
Tip: Explain what you validate and why.
API Testing Interview Cheatsheet
- Validate business rules
- Test positive & negative paths
- Don’t trust 200 alone
- Check schema & headers
- Handle edge cases
- Use automation where possible
FAQs – Top API Testing Interview Questions
Q1. Is Postman enough?
Yes for manual testing; automation helps.
Q2. REST or SOAP?
REST is primary; SOAP still relevant.
Q3. Biggest mistake?
Only checking status codes.
Q4. Freshers focus?
Fundamentals + Postman practice.
Q5. How to prepare fast?
Practice real APIs and scenarios.
