Skip to main content

Install

The package has no runtime dependencies and ships ESM, CommonJS and type definitions. It runs on Node.js, Bun, Deno and in the browser.

Authenticate

apiKey defaults to the STOPHY_API_KEY environment variable, so a bare new Stophy() picks it up. Pass a key directly with new Stophy("your key") or new Stophy({ apiKey: "your key" }).
Without a key, web search, YouTube search and YouTube transcripts still work:
Every other endpoint throws StophyError with code unauthorized and status 401 when called without a key.

Make a call

Methods follow the endpoint id. Nested ids are nested properties: youtube.comments.replies is stophy.youtube.comments.replies(...). Inputs and responses are typed from the API reference, so a missing required field is a compile error.

Get markdown

Pass { format: "markdown" } as the second argument to get a string:

Paging

Find endpoints

Handle errors and retries

StophyError has status, code, message, retryable, retryAfterSeconds and requestId. See Errors for every code. The SDK retries network errors and 429/5xx responses on its own, honoring Retry-After, before it throws. Set maxRetries: 0 to turn that off. StophyError only reaches your code after retries are exhausted.

Options

Per call, pass { signal } to cancel a request and { format: "markdown" } for markdown.

Usage and logs

These need an API key.
balanceMicros is your balance in millionths of a dollar: 1000000 is $1.