Install
Authenticate
api_key defaults to the STOPHY_API_KEY environment variable, so a bare Stophy() picks it up.
StophyError with code unauthorized and status 401 when called without a key.
Make a call
success, data, creditsUsed and requestId. data is a single dict, and lists are in data["results"].
Methods follow the endpoint id, with keyword arguments in snake_case. Nested ids are nested attributes: reddit.search is stophy.reddit.search(...), and google.maps.search is stophy.google.maps.search(...). A JSON field named from is passed as from_.
To point at one thing, send its link or its id, never both: video_url or video_id, place_url or place_id, user_url or username. The type checker shows the pair.
Async
AsyncStophy has the same methods. Await them.
Paging
Handle errors and retries
StophyError has status, code, retryable, retry_after_seconds and request_id. The message is str(error). See Errors for every code.
The SDK retries network errors and 429/5xx responses on its own, honoring Retry-After, before it raises. Set max_retries=0 to turn that off. StophyError only reaches your code after retries are exhausted.
Options
Use the client as a context manager, or call
close() when you are done.
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.