Install
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" }).
StophyError with code unauthorized and status 401 when called without a key.
Make a call
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.