Set your API key
SetSTOPHY_API_KEY, or pass the key to the client: new Stophy(key) or new Stophy({ apiKey }) in TypeScript, Stophy(api_key=...) in Python. Keep it in server code. Get one in the Quickstart.
Without a key, scrape, search, map and parse work within the free limits, and so do parsers, endpoints, signup and signup.poll. Any other method fails with apiKeyRequired. See Errors.
Make a request
- TypeScript
- Python
stophy.parsed() to read a site’s data at data.json. Parser options are the third argument, for example { page: 2 }.parsed calls scrape with { type: "json", parser }, and parsers() lists every parser. See Pre-built parsers.
Methods
There are no methods for agent, browser sessions, monitors, webhooks or feedback. Call those over HTTP with the same key.
crawl, batch.scrape and extract answer with an id. Pass it to .status or .result. See Read a crawl.
Errors and retries
CatchStophyError. It has code, message, retryable, status, details, plus retryAfterSeconds and requestId in TypeScript or retry_after_seconds and request_id in Python. The message says what to do. The codes are the API’s own. See Errors.
Each attempt waits up to 70 seconds, and eligible calls retry twice with a backoff or the delay the API returns. The SDK throws instead of waiting more than 60 seconds. A DELETE is not retried.
If a write may have run and cannot be replayed safely, the error carries outcomeUnknown (outcome_unknown in Python). Check whether the work finished before you send it again. To recover a replayable write, reuse its idempotency key and the same body. Pass your own as idempotencyKey (idempotency_key in Python) and read it back from error.details.idempotencyKey. See Timeouts.
Client options
- TypeScript
- Python
Pass
signal as a method’s second argument to cancel the request.