QA Interview Hub · Knowledge base · Quizzes · Українська

QA Fundamentals › Manual API testing

What is a REST API and what do you check in API testing?

REST is an architectural style: resources have addresses, actions are HTTP methods and the server keeps no state between requests. A 200 does not mean the API works, so a request is checked in layers: status, headers, body against the schema, system state (a follow-up GET or the database) and negative cases. An API test is faster and more stable than a UI test but cannot see rendering.

QA Fundamentals · Manual API testing

The endpoint answered 200. Does that mean the API works?

A tester sends a POST for a transfer, sees 200 and a green tick in Postman. The next day accounting finds a mismatch: the money was debited but the transfer does not exist in the system. The status code only said the server answered without an error, not that the right thing was done. This lesson is about what a REST API is, how API testing differs from testing through the interface and which layers a check of a single request consists of.

How it works and why. REST (Representational State Transfer) is an architectural style described by Roy Fielding: a set of constraints, not a protocol. In practice "REST API" almost always means an HTTP API with JSON. Each constraint gives the tester a concrete thing to check:

  • Resources at addresses. Entities (/transfers, /transfers/t-501) have stable URLs. A test checks the collection, a single resource and nested paths.
  • A uniform interface. An action is expressed by an HTTP method (GET reads, POST creates, PUT and PATCH change, DELETE removes) and the result by a status code. If an endpoint GET /deleteUser?id=5 changes data, the interface is broken, and that is a risk (a prefetch or a crawler can call it).
  • No state between requests. The server does not remember the previous request: the token, the language and the parameters arrive in every one. So requests can run in any order, and a dependency between tests appears only through data in the system (create, then read).
  • Representations. A resource is returned as JSON or another format described by the Content-Type header. The client and the server must understand field types, the date format and the amount format in the same way.

An API test works below the interface: it sends a request directly and sees what the browser hides (headers, exact types, every error code). It is faster and more stable than a UI test, and it finds bugs earlier, when there is no screen yet. The price is that it cannot check the display or usability.

The layers of checking one request

1. Status code201 Created, not "something successful"2. HeadersContent-Type, Location, cache, CORS3. Bodyfields, types, values, error format4. System stateGET after POST, a DB row, side effects5. Non-functionalresponse time, security, limits
Figure 1. A check does not end at the status code. The highlighted layer is the one most often skipped.

Example: from "200, so it is fine" to five checks. The tester sent a request and looked only at the status:

POST /api/transfers HTTP/1.1
Authorization: Bearer <token>
Content-Type: application/json

{"from": "acc-1", "to": "acc-2", "amount": 100.50, "currency": "UAH"}

HTTP/1.1 200 OK
Content-Type: application/json

{"id": "t-501", "amount": "100.5", "currency": "UAH", "status": "done"}

Status 200 means "success", so the test is "green". Now go through the layers. The first three are visible in the response itself, the rest need a second request and the database:

1. Status:   expected 201 Created (per the spec), got 200
2. Headers:  no Location with the path of the new resource
3. Body:     amount must be the number 100.50, a string "100.5" came back
             status must be "pending" per the contract, "done" came back
4. State:    GET /api/transfers/t-501 → 404 (the record was not created)
             no row in transfers and no entries in ledger in the DB
5. Negative: the same with amount = -5, without a token, with a foreign account

How to read it. The first three points are found from the response: creating a resource is expected to be 201 with a Location header (RFC 9110), and the type of the amount field deviates from the contract. The fourth point is impossible without a second request: only a GET after the POST or a database query shows that the record did not appear and there are no ledger entries. The fifth (negative cases) checks that the system refuses where it should. The same failure can show up on several layers, so start with the cheapest (status and body) and move on to the system state.

Limits and alternatives. The word "REST" is used in three senses, and it helps to tell them apart in an interview. Strict REST includes hypertext links (HATEOAS), but most public "REST" APIs have none and are really HTTP APIs with resource addresses. There are RPC-style APIs (POST /transfers/create) and they are tested with the same layers, only without the expectation that the method carries semantics. Other approaches have their own check points: GraphQL has a single endpoint and errors often arrive in the body with status 200; gRPC works with typed messages over HTTP/2, and Postman or curl are less convenient there. An API test does not replace a UI test: it will not show that a button is covered or an amount is displayed wrongly. And it does not see what the client does with the response.

Common mistakes.

  • Checking only the status code: a body with wrong types or values passes unnoticed, and another service finds the mismatch later in production.
  • Not checking the state after changes: a 201 with no record in the system is a serious bug that a status-only test will not see.
  • Testing only the happy path: the most interesting defects live in invalid data, missing fields, foreign IDs and a missing token.
  • Relying on the order of requests between tests: a test that works only after another one breaks in a parallel run. Each test prepares its own data.
  • Treating "REST" and "JSON" as the same thing: the format does not guarantee that actions match the HTTP methods.

Check yourself

POST /orders returns 201 and a correct body, but a customer complains the order is not visible in the list. Which two layers of checking have you not covered yet and how do you cover them?

Answer

The system state layer. Make GET /orders/{id} and GET /orders (is the record in the collection, do the fields match) and, if needed, check the DB row and side effects (an event, a queue, an email). Also the headers layer: the list may be cached (Cache-Control, ETag), and the new record appears with a delay.

Why is the answer "status 200, but the body has {"error": "…"}" a problem for API testing?

Answer

Because status codes exist so that clients and intermediaries (load balancers, caches, monitoring) can tell success from failure without reading the body. When the error hides under 200, monitoring says "all good" and a status check passes. The exception is GraphQL, where execution errors usually arrive in the errors field with status 200 (a request that fails to parse or validate gets 4xx under the GraphQL over HTTP spec with graphql-response+json), so that field is what you check there.

In an interview. Junior: REST is a style where resources have addresses and actions are performed by HTTP methods. I check the status code, the body (fields, types, values), headers, negative cases with invalid data and without authorisation, and that the change really happened, through a following GET or in the database. Middle/Senior: For each request I go through layers: status, headers, body against the schema, system state, non-functional properties. I watch state and side effects especially, because the defects invisible from the status live there. I keep tests independent, prepare data inside the test and log deviations from the specification as separate bugs. API checks complement UI tests rather than replace them: they are faster and more stable but do not see the display.

More articles in this chapter