What API testing is and how it works
API testing is checking an HTTP API directly, without a user interface: a test sends a request and compares the status code, headers, body and response time against expectations. Faults in the service surface earlier and more precisely this way than through the interface.
Five things are checked in an API. Functionality: the operation does what it promises. Contract: the response matches the specification and the schema. Authorisation: anonymous and third-party requests are rejected. Error handling: an invalid request receives the right refusal. Side effects: the data has actually changed. By purpose, such tests are integration, end-to-end and regression tests; behaviour under load is checked separately — that is the subject of the “Load testing” reference.
Every check is an exchange of HTTP messages: a request (method, address, headers, body) and a response (status code, headers, body). Methods, codes and headers as such are described in the “HTTP and REST” reference; here the point is how to check them.
The work runs as a pipeline. An OpenAPI specification describes the operations and response schemas. Test conditions are selected from it using test design techniques. The conditions turn into requests with checks — a Postman collection or tests in code. The suite runs in CI on every change, and the report shows which check failed.
Postman, tests in code or Playwright
| Tool | What tests look like | When to choose it |
|---|---|---|
| Postman | requests in a collection, checks written as JavaScript scripts; run in the app or through the Postman CLI | APIs are tested by testers, a quick start is needed, and requests are shared with the team |
| pytest and httpx | tests in Python in the service’s repository | tests are written and maintained by developers alongside the code; details in the “pytest” reference |
| Playwright | requests through the request fixture in the same tests as the browser | data needs to be prepared through the API before a UI test, or the server checked after actions in the browser |
What to check does not depend on the tool: the syntax changes, not the set of checks. Use the tool your team already writes on.
What to know in advance
- HTTP: methods, status codes, headers — the “HTTP and REST” reference
- Choosing checks: equivalence classes and boundary values — the “Test design” reference
- The JSON format: objects, arrays, value types
- JavaScript basics — for Postman scripts, the “JavaScript” reference
Section sources
the section is written from these pages- Test API functionality and performance in Postmanlearning.postman.com/docs/tests-and-scripts/test-apis/test-apis/(opens in a new tab)
- Test APIs and write scripts in Postmanlearning.postman.com/docs/tests-and-scripts/tests-and-scripts/(opens in a new tab)
- OpenAPI Specification v3.2.1spec.openapis.org/oas/v3.2.1.html(opens in a new tab)
- RFC 9110: HTTP Semanticsrfc-editor.org/rfc/rfc9110.html(opens in a new tab)
- API testingplaywright.dev/docs/api-testing(opens in a new tab)