How to fuzz test an API in API Spector

Roy de Kleijn Roy de Kleijn · · 3 min read
How to fuzz test an API in API Spector

Fuzzing hammers a request with malformed and hostile inputs to find the cases your happy-path tests miss: a crash, a 500, a leak, an injection that slips through. API Spector fuzzes a single request inline.

How API Spector approaches fuzzing

The fuzzer is spec-driven and single-fault, which is what keeps its findings precise rather than noisy:

  • It starts from a valid baseline. API Spector builds a schema-valid example from the request body, or from the operation's request schema when you point it at an OpenAPI spec. Every case is a mutation of that known-good payload, so you are testing one deviation from "correct", not random noise.
  • One fault per case. Each case changes exactly one field. When something breaks, the finding names a single cause instead of a tangle of changes you then have to bisect.
  • It is deterministic. Generation runs on a seeded pseudo-random generator, so the same seed produces the same cases. Any finding replays exactly, which makes it fixable and regression-testable.
  • It judges with oracles, not eyeballs. A case is only reported when the response breaks a rule: a 5xx on malformed input (the server crashed instead of rejecting with a 4xx), a 2xx on a schema-invalid request (input validation is missing), a status code the spec does not document for that operation, or a 2xx body that does not match the documented response schema.

The intensity level decides which mutations are in play, and each level is a superset of the one before it. That is the next thing you pick.

1. Open the fuzzer

Open a request and click the fuzz button at the right of the request tabs. Nothing is sent until you confirm, so you can set the run up first.

The fuzzer, with its level, cases, and seed

2. Pick a level

Choose how hard to push:

  • Basic: structural faults (wrong types, missing fields, broken JSON).
  • Standard: adds boundary values and "naughty strings".
  • Aggressive: adds injection probes and header tampering.

3. Set cases and seed

Set how many cases to generate and a seed. The seed makes the run reproducible, so a failure you find can be replayed exactly.

4. Run and read the findings

API Spector generates the cases, sends them against the request's own URL, auth, and environment, and reports the findings: which inputs produced an unexpected response, with the exact case that triggered it.

Why it matters

These are the defects that never show up in example-based tests. Fuzzing explores the inputs you would not think to write by hand, and the reproducible seed turns any finding into a fixable, re-runnable case.

Try it in API Spector

Free and open source. No account needed to use the app.

Keep reading