Skip to main content
Techdome
All Insights/Engineering Practice

API testing explained: types, what to automate, and tools

API testing checks an interface directly, below the UI. Learn the five main types, how mocking and test data fit in, and which tests to automate first.

Techdome Engineering
Techdome EngineeringEngineering Team
8 min read
Verified Architecture
API testing explained: types, what to automate, and tools

API testing means sending requests straight to an application's interface and checking the responses, without going through the user interface. It is faster and more stable than browser testing and it catches most logic bugs before a screen ever shows them. Start by automating the functional checks on your most important endpoints, then add contract, integration, load and security tests as the product grows.

Why test at the API layer

The API is where business rules live. A UI test that clicks through five screens to confirm a discount was applied is slow and breaks when a button moves. An API test sends one request and checks the price.

AspectUI testAPI test
SpeedSeconds to minutesMilliseconds to seconds
Fails becauseA button moved, a page was slow, or the logic brokeThe logic broke
ReachOnly what the screen exposesBad input, missing permissions, odd sequences
Fits in every pull requestRarelyYes

This holds for a REST API, a GraphQL endpoint or an internal service call. The protocol changes how you build requests, not why you test.

The five main types

TypeQuestion it answersRun it
FunctionalDoes this endpoint do what it should?Every pull request
ContractDo provider and consumers agree on the shape?Every pull request
IntegrationDoes it work with the real database and queue?On merge
LoadHow does it behave under traffic?Before launch, after query changes
SecurityHow does it fail under hostile input?On a schedule, before releases

Functional tests

For each endpoint, check the happy path and the failures:

  • The status code and response body for valid input.
  • Validation errors for missing, malformed or out-of-range fields.
  • Authentication and authorization: a missing token returns 401, a valid token without permission returns 403.
  • Edge cases, such as empty lists, very long strings and duplicate submissions.

Assert on the parts of the response that matter. Over-specified assertions make tests brittle.

Contract tests

A contract test checks that a provider and its consumers agree on field names, types, required fields and status codes. It is most valuable when different teams own the two sides, or when a mobile app talks to a backend that ships on a different schedule. In a microservices setup, contract tests catch a breaking change in one service before it breaks another.

Provider-driven contracts validate the API against its published specification, such as an OpenAPI document. Consumer-driven contracts let each consumer record what it relies on, and the provider's build verifies it still holds.

Integration tests

Integration tests run the API against its real collaborators: the database, the cache, a message queue. Use a disposable environment, such as containers started for the test run, so each run begins from a known state. Focus on the seams where things break: queries, transactions, serialization and migrations.

Load tests

Load tests measure response times, error rates and the point where the service starts to degrade. Define what you are measuring first, for example 95th percentile latency at an expected request rate, and test against an environment that resembles production.

Security tests

Start with the common API weaknesses OWASP publishes:

  • Broken object-level authorization: can user A read user B's record by changing an ID?
  • Weak authentication and missing rate limits.
  • Excessive data exposure and injection through query parameters or bodies.

Automated scanners help, but authorization bugs are logic bugs, and they are best caught by tests you write for your own rules.

Mocking and test data

Mocking replaces a dependency with a controlled stand-in. Use it when the real thing is slow, costly, unavailable or hard to push into a failure state. A mock of a payment provider lets you test what your code does when the provider times out or returns a decline, which is hard to trigger on demand with the real service.

Test data decides whether your suite is trustworthy or flaky:

  • Create the data each test needs and clean it up, so tests do not depend on run order.
  • Use fixtures or factories for repeatable records, and unique values where fields must be unique.
  • Keep real personal data out of test environments. Synthetic data avoids compliance problems.

Running tests in CI

Tests only protect you if they run automatically. Wire them into CI/CD so that every pull request runs the fast tests and a merge runs the full set.

  1. 01Pull requestfunctional and contract
  2. 02Mergeintegration, fresh environment
  3. 03Scheduleload and deeper security, before releases

Fail the build on a failing test and publish the report. Keep the pipeline fast, because a slow suite gets skipped.

What to automate first

If you have no automated API tests today, work in this order:

  1. The critical path: sign-in, the core create-and-read flows, and anything that touches money or personal data.
  2. A smoke test that hits every endpoint once and checks it responds, so deployments fail loudly.
  3. Every bug you fix. A test that reproduces the bug is the cheapest regression testing there is.
  4. Contract checks for any API consumed by another team or a mobile app.
  5. Load and security tests for the endpoints with the most traffic or the most sensitive data.

A small set of tests on the right endpoints beats hundreds of shallow ones. Before calling an endpoint covered, check:

  • The happy path returns the right status and body
  • Invalid and missing input return clear errors
  • A missing token returns 401 and a token without permission returns 403
  • Test data is created and cleaned up by the test itself
  • The test runs in the pipeline, not only on a laptop

How this looks at Techdome

We build Sparrow, an open-source, local-first API testing, mocking and monitoring suite, so the topics in this article are ones we work on directly. Sparrow is built with Rust, TypeScript and SQLite, and it is listed on the Microsoft Azure Marketplace. It reached #4 Product of the Day on Product Hunt in two separate launches.

Our software testing and QA work follows the order above. For a distributed-systems engagement with a global technology services corporation, the results included 100% integration tests (A Global Technology Services & Software Corporation).

Takeaways

  • Test the API directly: it is faster, steadier and closer to the business rules than UI tests.
  • Cover five types over time: functional, contract, integration, load and security.
  • Mock at system edges and use real components inside, and manage test data so runs are independent.
  • Run fast tests on every pull request and slower ones on merge or on a schedule.
  • Start with the critical path, a smoke test and a regression test for every fixed bug.

Have a project like this? Talk to our engineers.

FAQ

Questions readers ask

What is API testing?

API testing sends requests to an application's endpoints and checks the status codes, response bodies and side effects. It validates business logic and integrations without driving the user interface.

What is the difference between functional and contract testing?

Functional tests check that an endpoint behaves correctly. Contract tests check that the shape of its requests and responses matches what consumers expect, so a change does not silently break them.

Should I mock the database in API tests?

Usually not for integration tests, where a real database in a disposable container gives more trustworthy results. Mock third-party services you do not control, and keep the database real where queries matter.

How many API tests are enough?

There is no universal number. Cover the critical flows, every endpoint at least with a smoke test, and each bug you have fixed. Add more where failures would cost the most.

Can API tests replace UI tests?

They replace most of them, since logic is faster to verify at the API. Keep a few end-to-end UI tests for the journeys where the interface itself matters.

Continue reading

More foundry teardowns

View all
Blueprint-style illustration of five phases from a drawing board to a launched product, rising along a path
Studio ArchitectureAugust 2026

The Techdome Blueprint: how we take a product from a blank repo to production in eight weeks

Rahul Joshi
Rahul JoshiChief Executive Officer
+
+
+
+
Healthcare AIOct 28, 2026

Asynchronous vs synchronous telehealth: which to build first

Techdome Engineering
Techdome EngineeringEngineering Team
+
+
+
+
Healthcare AIOct 28, 2026

Telehealth compliance checklist for the US and UK

Techdome Engineering
Techdome EngineeringEngineering Team
+
+
+
+
Healthcare AIOct 28, 2026

How to build a GLP-1 telehealth platform

Techdome Engineering
Techdome EngineeringEngineering Team
+
+
+
+
Healthcare AIOct 28, 2026

Telehealth metrics and KPIs: the numbers that matter

Techdome Engineering
Techdome EngineeringEngineering Team
A technical illustration comparing queued task delivery with retained event streaming.
System DesignOct 26, 2026

Message queues vs event streams: SQS, RabbitMQ, Kafka

Techdome Engineering
Techdome EngineeringEngineering Team
Illustration of webhook retry flow using a stable idempotency key, de-duplication store, and dead-letter queue.
System DesignOct 26, 2026

Webhook retries and idempotency keys, together

Techdome Engineering
Techdome EngineeringEngineering Team
Blueprint-style illustration of a server rack behind a layered firewall shield, with a PHP version badge being upgraded
Engineering PracticeOct 22, 2026

PHP2Shell: how to check and protect your PHP site

Techdome Engineering
Techdome EngineeringEngineering Team
"Automating mortgage back-office work with n8n"
n8n Automation

"Automating mortgage back-office work with n8n"

Techdome Engineering
Techdome EngineeringEngineering Team
3D illustration of an AI agent connected to calendar, database and phone tools, with a sound wave and a small knowledge graph
Studio ArchitectureSeptember 2026

Building AI agents that hold up in production: what we learned from voice, interviews and GraphRAG

Rahul Joshi
Rahul JoshiChief Executive Officer
Interface illustration of a browser window with three gauge dials, a heavy block swapped for a light placeholder, and images compressed
Engineering PracticeSeptember 2026

Making a Next.js site fast: the fixes that moved Core Web Vitals on techdome.io

Rahul Joshi
Rahul JoshiChief Executive Officer
Isometric illustration of one platform split into separate clinic compartments, with a shield, an access gate and an audit log
Healthcare AIAugust 2026

Engineering HIPAA-ready telehealth platforms: the decisions we make first

Rahul Joshi
Rahul JoshiChief Executive Officer
Pipeline illustration of an automation workflow with a queue feeding two workers, a retry loop, an alert bell and a review tray
n8n AutomationAugust 2026

Production n8n: the patterns that keep automation from failing quietly

Rahul Joshi
Rahul JoshiChief Executive Officer