What is API testing, and why test at the API layer at all?
API testing checks the service layer directly — you send a request and assert on the response, without a browser. You verify status, body, headers and behaviour where the logic actually lives.
API testing checks the service layer directly — you send a request and assert on the response, without a browser. You verify status, body, headers and behaviour where the logic actually lives.
You test here because it's faster, more stable and closer to the bug than the UI. A broken business rule shows up in the API response long before it surfaces as a mislabelled button, and an API test doesn't flake on a slow render.
A discount rule that only failed for carts over $500 was invisible in UI tests — the total looked plausible. One API call with a $600 cart returned the wrong total, caught in seconds.
- Test the service directly: request in, assert on the response
- Faster and less flaky than UI — no browser, no render waits
- Catches broken logic at the layer where it lives
No — the UI has its own bugs (rendering, wiring, accessibility). API tests cover logic cheaply so the few UI tests you keep can focus on the user journey, not business rules.
The middle layer — more than end-to-end UI tests, fewer than unit tests. Wide enough to cover integrations, cheap enough to run on every push.
Don't say "API testing replaces UI testing" — they cover different failure modes. Saying one removes the need for the other reads as junior.