API Testing

API Testing for QA Engineers: From Fundamentals to Advanced Testing

Build practical API testing skill across contracts, services, data, dependencies, concurrency, eventual consistency, observability, and regression design.

JobPilot Editorial · Practical career guides21 min read
In this guide

Strong API testing connects an external request to behavior across gateways, services, databases, events, and dependencies. The goal is not maximum assertions—it is enough evidence to detect meaningful risk quickly.

This skill-oriented guide progresses from endpoint checks to reliable system-level API regression without duplicating the interview-answer format.

Follow the request through the system

API validation layers
Request
  → Gateway / API boundary
  → Authentication and authorization
  → Service and business rules
  → Database / events / dependencies
  → Response and observable outcome
LayerQA focus
RequestMethod, URL, headers, encoding, schema, identity
GatewayRouting, media type, limits, authentication, tracing
ServiceRules, state transitions, calculation, authorization
Data/dependenciesIntegrity, atomicity, messages, downstream failures
ResponseStatus, schema, values, headers, latency, safe errors

Establish a contract-first foundation

Collect the OpenAPI or equivalent contract, business rules, payload examples, permission matrix, state model, and error format. Resolve contradictions before automating them.

  • Required, optional, and nullable fields are distinct
  • Formats, ranges, enums, and defaults are explicit
  • Error codes and schemas are documented
  • Compatibility and deprecation rules are known
  • Sensitive fields and logging expectations are identified

Design CRUD tests around state and ownership

For create, read, update, and delete, test more than one happy request. Assert identity, ownership, defaults, timestamps, relationships, and repeat operations.

CRUD evidence
Create  → 201 + generated ID + persisted owner
Read    → accurate representation + access rules
Update  → intended fields change; others remain stable
Delete  → documented later-read and repeat-delete behavior

Use controlled, uniquely named data. Cleanup should be safe and retain evidence needed to diagnose failures.

Authentication, authorization, and data integrity

Build a compact actor/resource/action matrix. Cover unauthenticated, ordinary user, owner, non-owner, privileged role, disabled account, and expired credentials as applicable.

For integrity, verify uniqueness, references, totals, precision, audit fields, and transactional rollback.

Chaining, schema, pagination, filtering, and sorting

Use a few end-to-end chains to prove workflows while keeping most tests independently set up. Validate schemas at boundaries and business meaning separately.

  • Capture identifiers explicitly; do not depend on collection order
  • Seed enough records to cross page boundaries
  • Use stable sort keys and tie-breakers
  • Combine filters that intersect and conflict
  • Verify totals or cursors and no duplicate or missing records
  • Test encoding, special characters, null, and empty values

Idempotency, concurrency, and duplicate prevention

Concurrency tests expose races that sequential tests miss. Send simultaneous updates, reservations, or creates against controlled state and assert the documented winner, conflict, or merge.

For retryable creation, verify idempotency keys are scoped correctly, retained for the documented period, and reject conflicting payload reuse where required.

Retries, rate limits, and dependency failures

Use fault injection, stubs, or controllable dependencies to produce timeouts, slow responses, malformed payloads, 4xx/5xx responses, and unavailable services.

  • Retries are bounded and limited to appropriate failures
  • Backoff and Retry-After behavior are respected
  • State-changing retries cannot duplicate work
  • Circuit-breaker or fallback state is visible and recoverable
  • Errors are stable, safe, and traceable
  • Limits isolate users or keys according to policy

Eventual consistency and asynchronous workflows

Some accepted requests complete later. Assert the immediate acknowledgement, status resource or event, eventual terminal state, timeout behavior, and duplicate-message handling.

Asynchronous API flow
POST /exports -> 202 Accepted + operationId
GET /operations/{id} -> pending
... bounded polling ...
GET /operations/{id} -> completed + result link

Database checks, logs, and correlation IDs

Use database validation selectively when public behavior cannot prove a critical persistence rule. Use correlation identifiers to connect the request, logs, dependency calls, and events without asserting every internal line.

  • Committed rows match business values and owner
  • Failed transaction leaves no partial records
  • Audit timestamp and actor are correct
  • Correlation ID is returned or discoverable and propagated
  • Logs exclude tokens, passwords, and unnecessary personal data

Build a sustainable API regression suite

Organize coverage by risk and feedback speed: contract smoke on each change, critical business flows in CI, broader combinations on a suitable schedule, and targeted performance or security suites in authorized environments.

  1. Tag by service, risk, feature, and execution profile—not test order.
  2. Run independently with isolated, parallel-safe data.
  3. Show sanitized request, response, expected rule, and correlation ID on failure.
  4. Quarantine only with ownership and expiry; keep retry metrics visible.
  5. Review duplication and production incidents regularly.

Related guides