@pb33f/wiretap
v0.7.3
Published
The world's coolest OpenAPI contract compliance API Proxy testing tool.
Downloads
6,961
Readme
wiretap

wiretap is an API diagnostics, validation, proxying, and mocking tool for teams building against OpenAPI contracts.
Run it locally or in a pipeline to inspect real HTTP traffic, validate requests and responses, serve static frontends, replay HAR files, and simulate APIs from an OpenAPI description before the backend exists.
This is an early tool and in active development. Try it out and tell us what breaks, what helps, and what you want next.

Quick start
Install
Homebrew
brew install pb33f/taps/wiretapnpm
npm install -g @pb33f/wiretapcURL
curl -fsSL https://pb33f.io/wiretap/install.sh | shDocker
Images are published to both Docker Hub and GitHub Container Registry:
docker pull pb33f/wiretap
docker pull ghcr.io/pb33f/wiretapdocker run -p 9090:9090 -p 9091:9091 -p 9092:9092 --rm -v \
$PWD:/work:rw pb33f/wiretap -u https://somehostoutthere.com
docker run -p 9090:9090 -p 9091:9091 -p 9092:9092 --rm -v \
$PWD:/work:rw ghcr.io/pb33f/wiretap -u https://somehostoutthere.comThe default ports are 9090 for the API gateway, 9091 for the monitor UI, and 9092 for the monitor websocket.
Windows
Download the Windows build for your CPU from the latest GitHub release.
Run as a validation proxy
Send traffic through wiretap and forward it to a real upstream API:
wiretap -u https://api.pb33f.comAdd an OpenAPI contract to validate traffic:
wiretap -u https://api.pb33f.com -s ./openapi.yamlYour client calls http://localhost:9090; wiretap validates and proxies the request, validates the response, and streams everything to the monitor UI.
Mock APIs from OpenAPI
wiretap is not only a passive proxy. It can run as a contract-driven API simulator.
Use full mock mode when the backend does not exist, is unstable, or should not be called during client tests:
wiretap -s ./openapi.yaml --mock-modeIn mock mode, no traffic is sent upstream. wiretap matches the incoming request to the OpenAPI operation, validates the request, chooses an appropriate response, and generates the response body from schemas and examples.
Mocking capabilities include:
- Generate all responses from an OpenAPI contract with
--mock-mode. - Mock only selected paths with
mockModeListinwiretap.yaml, while other paths still proxy to an upstream API. - Select named OpenAPI examples by sending a
Preferred: ExampleNamerequest header. - Override the returned status code with
wiretap-status-code: 404after a successful mock body is generated. - Use
--hard-validationto reject invalid mock requests, or--mock-bypass-validation/wiretap-bypass-validation: trueto keep serving chosen examples for malformed fixture traffic. - Enable
--strict-modeto detect undeclared properties, parameters, headers, and cookies. - Return non-JSON examples such as
text/plainortext/htmlwithout JSON string wrapping. - Run with no upstream URL in full mock mode; an OpenAPI contract is the required input.
Path-scoped mocking example:
redirectURL: https://api.pb33f.com
contract: ./openapi.yaml
mockModeList:
- /checkout/**
- /beta/*wiretap -c ./wiretap.yamlRequests under /checkout/** and /beta/* return generated mocks. Everything else is proxied and validated against https://api.pb33f.com.
Static mock fixtures
For exact fixture-based mocks, point wiretap at a static mock directory:
wiretap -u https://api.pb33f.com --static-mock-dir ./mocksDirectory layout:
./mocks/
mock-definitions/
get-product.json
body-jsons/
product.jsonDefinition example:
{
"request": {
"method": "GET",
"urlPath": "/products/123",
"queryParams": {
"view": "full"
}
},
"response": {
"statusCode": 200,
"header": {
"x-mock": "wiretap"
},
"bodyJsonFilename": "product.json"
}
}Static mocks can match method, host, path, headers, query parameters, and JSON or form request bodies. Response bodies can be inline or loaded from body-jsons/, and can use request data with template expressions such as ${queryParams.view}.
If no static mock matches, wiretap falls back to the normal proxy/mock handler. Mock definition JSON files are watched and reloaded while the service is running.
Multi-spec mode
Got more than one OpenAPI contract? Hand wiretap a list, or point it at a directory and let it discover them.
wiretap -u https://api.pb33f.com --specs ./users.yaml,./orders.yaml,./billing.yamlwiretap -u https://api.pb33f.com --spec-dir ./contractswiretap routes each request to the spec that owns it and reports duplicate or ambiguous routes across contracts at startup.
Use --dry-run to discover, analyze, and print the conflict report without starting the proxy. It exits non-zero on conflicts or load errors, which makes it useful in CI.
wiretap --spec-dir ./contracts --dry-runFull details: Multi-spec mode.
HAR and headless workflows
Load a HAR file into the monitor:
wiretap --har ./traffic.harValidate a HAR file against OpenAPI without running the proxy:
wiretap --har ./traffic.har --har-validate -s ./openapi.yaml --har-allow /apiStream validation violations to a report file while wiretap runs:
wiretap -u https://api.pb33f.com -s ./openapi.yaml \
--stream-report \
--report-filename ./wiretap-report.jsonl