Back To Blogs

API Testing for Beginners: What to Check in Every Endpoint

Most of what a web app does happens behind the UI, in its API. Testing the API directly is faster than testing through the browser, finds bugs earlier, and catches problems the UI hides, like a server that accepts an order with no address because only the front end checked it.

HTTP in five minutes

An API request has:

  • A method: GET (read), POST (create), PUT/PATCH (update), DELETE (remove)
  • A URL: https://api.example.com/v1/orders/123
  • Headers: e.g. Authorization: Bearer <token>, Content-Type: application/json
  • A body (for POST/PUT/PATCH), usually JSON

The response has a status code, headers and usually a JSON body.

Status codes to know

CodeMeaningTypical case
200OKSuccessful read or update
201CreatedResource created
204No ContentSuccessful delete
400Bad RequestInvalid input
401UnauthorizedMissing or invalid authentication
403ForbiddenAuthenticated but not allowed
404Not FoundResource doesn't exist (or is hidden from you)
409ConflictDuplicate, or state conflict
422UnprocessableValid JSON, invalid business data
429Too Many RequestsRate limited
500Server ErrorA bug on the server: always worth reporting

The endpoint checklist

1. Happy path

  • Correct status code (201 for create, not 200)
  • Response body has the expected fields, types and values
  • The change really happened: a GET afterwards returns the new state

2. Validation

  • Missing required fields → 400/422 with a clear message
  • Wrong types ("quantity": "two"), out-of-range values (0, -1, huge numbers)
  • Empty strings and whitespace-only strings
  • Extra unexpected fields are ignored or rejected, never silently applied (e.g. "price": 0)

3. Authentication and authorization

  • No token → 401
  • Invalid or expired token → 401
  • A valid user accessing another user's resource → 403 or 404 (test by changing the ID)
  • Admin-only endpoints refuse normal users

4. Business rules

  • Rules enforced on the server, not just in the UI (coupon limits, capacity, stock)
  • Idempotency: sending the same "create order" twice doesn't create two orders, if the API promises that
  • State transitions: you can't cancel an already cancelled booking

5. Errors and robustness

  • Malformed JSON → 400, not 500
  • Very large bodies are rejected
  • Error responses don't leak stack traces, SQL or internal paths

6. Non-functional

  • Response time is reasonable under normal load
  • Pagination works: first page, last page, beyond the last page
  • Rate limits behave as documented

Your first automated API test

With Playwright's request context (no browser needed):

import { test, expect } from '@playwright/test';

test('rejects a booking for more guests than the room holds', async ({ request }) => {
  const res = await request.post('/api/bookings', {
    data: { roomId: 'harbour', date: '2026-12-01', start: '10:00', durationMin: 60, guests: 7, name: 'QA' },
  });
  expect(res.status()).toBe(400);
  const body = await res.json();
  expect(body.error.message).toMatch(/capacity|guests/i);
});

The same checks work in Postman, REST Assured (Java), pytest + requests (Python) or any HTTP client. See Postman vs code-based API testing.

Where API bugs hide

  • The UI validates, the API doesn't: submit directly and the rule disappears
  • Insecure direct object references: /orders/124 returns someone else's order
  • Wrong status codes: errors returned as 200 with { "success": false }
  • Inconsistent data: the list endpoint and the detail endpoint disagree

Practise with real requests

Open DevTools → Network while you use the apps in QAUnlocked Practice Labs. Each action is an API call you can inspect, replay and tweak, which is a great way to see whether the server enforces the same rules as the form. (Our DevTools for testers guide shows how.)

API testingRESTPostmanbeginners

Comments

0 Comments

Be the first to comment.