Skip to content
TargetQA

Testing Fundamentals

API Testing Interview Questions & Answers

API testing interview questions on REST, HTTP methods and status codes, authentication, REST Assured, Postman, schema and contract testing, and real-time scenarios.

50 questions17 Beginner21 Intermediate12 Advanced
Interactive Practice Sandbox

Practice API Testing Online with Zero Setup

Apply these interview concepts directly in your browser. Solve 64+ interactive API automation challenges in Java (REST Assured), Python (requests), or Playwright against real practice endpoints.

Start API Coding Challenges

Interview Questions

Showing 15 of 50 questions

  1. API testing validates the business logic, data, security and performance of services directly at the request/response layer, without a UI. It is faster and more stable than UI testing and catches defects earlier in the pipeline.

  2. REST is an architectural style that uses HTTP methods on resources and usually exchanges JSON, while SOAP is a strict XML-based protocol with a WSDL contract and envelope. REST is lighter and dominant for modern web APIs; SOAP is still found in banking and legacy enterprise systems.

  3. GET reads, POST creates, PUT replaces, PATCH partially updates and DELETE removes a resource. GET, PUT, DELETE, HEAD and OPTIONS are idempotent, meaning repeating the same call leaves the server in the same state; POST and PATCH are not guaranteed to be.

  4. 2xx means success (200 OK, 201 Created, 204 No Content), 3xx is redirection, 4xx is a client error (400, 401, 403, 404, 409, 422, 429) and 5xx is a server error (500, 502, 503, 504).

  5. Path parameters identify a specific resource and are part of the URL path, like /users/42. Query parameters filter, sort or paginate a collection and come after the ?, like /users?role=admin&page=2.

  6. I validate the status code, response time, headers such as Content-Type, the body values and data types, the JSON schema, and the side effect in the database or downstream systems.

  7. I organise requests into collections, use environments and variables for base URLs and tokens, write assertions in the Tests (post-response) script tab, and run collections in CI with Newman or the Postman CLI.

  8. I have tested Basic auth, API keys, Bearer tokens such as JWT, and OAuth 2.0 flows like client credentials and authorization code with PKCE. For each I test valid, missing, expired, malformed and insufficient-scope tokens.

  9. REST Assured uses a given/when/then BDD style: given sets headers, auth and body, when sends the request, and then asserts the status code and body using Hamcrest matchers.

  10. I keep a base RequestSpecification with base URI, auth and logging, service classes per resource that wrap endpoints, POJOs for request and response payloads, config per environment, and TestNG or JUnit for execution and reporting.

  11. I keep a JSON Schema file describing required fields, types and formats, and assert the response against it. In REST Assured I use the json-schema-validator module's matchesJsonSchemaInClasspath.

  12. Contract testing verifies that a consumer and provider agree on the request and response format, using a shared contract, without deploying both services together. Consumer-driven tools like Pact record consumer expectations and replay them against the provider in its own pipeline.

  13. Playwright provides the request fixture and APIRequestContext to send HTTP calls in the same test runner as UI tests. I use it for pure API tests and to set up data or log in through the API before a UI test.

  14. I would send missing mandatory fields, wrong data types, boundary and overlong values, invalid formats like a bad email, duplicate records, invalid or missing auth, an unsupported Content-Type, and malformed JSON, and expect clear 4xx responses with no record created.

  15. I chain requests by extracting values like orderId from one response and passing them into the next, asserting each step and the final state. Test data is created in setup and cleaned up after, so the flow is independent and repeatable.