Install the SDK
The SDKs are open source: stubsmith-python on PyPI and stubsmith-node on npm, both MIT. The Python SDK needs Python 3.9 or later, the Node SDK Node 22.12 or later.
pip install stubsmithimport stubsmith
# Add to your application entrypoint or conftest.py.
# The project key is read from STUBSMITH_API_KEY.
stubsmith.install(url="https://ingest.stubsmith.dev/v1/captures")
# Calls made with requests or httpx are now captured.npm install stubsmithimport { install } from "stubsmith";
// CommonJS: const { install } = require("stubsmith");
// Call before importing HTTP clients. The project key is read from STUBSMITH_API_KEY.
install({ url: "https://ingest.stubsmith.dev/v1/captures" });
// Calls made with node:http, node:https and global fetch are now captured,
// so axios, got and node-fetch are covered too.In Python, install() instruments whichever of requests and httpx your app already has. If you are starting without either, install the one you use with it: pip install "stubsmith[requests]" or pip install "stubsmith[httpx]". The testing extra adds responses, which only register and register_template need; the stubsmith.testing module is Python-only.
In Node, options are camelCase (apiKey, url, sampleRate). The environment variables are the same in both SDKs: STUBSMITH_API_KEY, STUBSMITH_API_URL, STUBSMITH_BUNDLE, STUBSMITH_DEBUG, STUBSMITH_MASK_SALT and STUBSMITH_FLUSH_TIMEOUT. The rest of this section describes the Python SDK; the Node SDK's README lists the Node specifics.
Calling stubsmith.install() patches requests.sessions.Session.request and Session.send, and, for httpx, Client.send and AsyncClient.send (whichever library is importable). The module-level helpers requests.get, requests.post and the rest are covered by that, because each one builds a Session and calls Session.request. Since SDK 0.2.0, a PreparedRequest built by hand and sent with Session.send() is also captured. Traffic sent through urllib, urllib3, http.client or aiohttp is not captured. The SDK applies your masking rules fail-closed, computes structural fingerprints, and forwards the masked payload asynchronously to the ingest endpoint. The call is fire-and-forget by design so that capture can never block or raise an exception in the caller. If you want to confirm that capture is working, fingerprints appear in the dashboard as soon as the first capture is received and approved. To surface send and sync failures on stderr while debugging, pass debug=True to StubSmith() or set the environment variable STUBSMITH_DEBUG=1 before your process starts. Either form activates the same path. This does not change the fire-and-forget contract; it only makes failures visible.