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, Google search, Google News, YouTube search, video details and transcripts, Reddit search and Google Maps search still work. Here is Google search:
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: reddit.search is stophy.reddit.search(...), and google.maps.search is stophy.google.maps.search(...). Inputs and responses are typed from the API reference, so a missing required field is a compile error. To point at one thing, send its link or its id, never both: videoUrl or videoId, placeUrl or placeId, userUrl or username. The types show the pair. Every response is { success, data, creditsUsed, requestId }. data is a single object, and lists are in data.results.

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.

Usage and logs

These need an API key.
balanceMicros is your balance in millionths of a dollar. One credit is 1500, so divide by 1,500 to get credits.