Skip to main content

Stophy for Python

Search, read, and act on the web. This is the typed Stophy client for Python, with a sync and an async class.

Install

pip install stophy

Example

from stophy import Stophy

stophy = Stophy()
page = stophy.scrape(url="https://example.com", formats=["markdown"])
print(page["data"].get("markdown"))

That call needs no key. Every method and result is typed, and each method sends one call to the Stophy API and returns its JSON as a dict. scrape returns success and data, and map returns success and links. Arguments are keyword-only and snake_case. For async code, use AsyncStophy: it has the same methods, and you await each call.

Pick a method

Method Use it to
search Search the web, news, images, research papers or YouTube videos
scrape Read one page as Markdown, HTML, links, a screenshot or JSON
parsed Read a site's own data, such as Reddit posts or Google Maps places, as JSON
map List the pages on a site, to find the right one before you read it
parse Turn a PDF, Word, Excel or PowerPoint file, or a picture of text, into Markdown
crawl, batch.scrape Read a whole section of a site, or a list of URLs, in the background
extract Pull the fields you name from pages, each checked against the page
browser.task Click through a public site in a cloud browser to search, filter or fill a form
limits, usage, logs Read your balance, your all-time usage and your recent calls

limits returns the balance in dollars as balanceUsd, with your rate limit. scrape, search, map and parse work without a key, within a small free allowance, and so do parsers, endpoints and signup. Every other method raises a StophyError with the code apiKeyRequired.

Read a site with a parser

stophy.parsed("google-maps", url) calls scrape with the format {"type": "json", "parser": ...} and puts the result in data.json. The parser name is typed as ParserName, and stophy.parsers() returns each parser with the page it reads and what it returns. Extra keyword arguments are the parser's options, such as page=2 for the next page. The idempotency_key keyword sets the request's Idempotency-Key header. Paging needs an API key.

Run a job in the background

crawl, batch.scrape, extract and browser.task answer at once with an id, which browser.task returns as data["id"] and the others return at the top level. Read the result with crawl.status(id=...), batch.scrape.status(id=...), extract.result(id=...) or browser.task.status(id=...). crawl and batch.scrape also have cancel(id=...), which stops the job and keeps the pages already read.

A crawl status is scraping until it is completed. While pages are left to read, the answer has next, a link with a cursor. Send that cursor with the same id to get only the pages finished since. extract.result raises a StophyError with the code notFound until the result is ready. A job and its result are kept for 24 hours.

API key

Get a key at stophy.dev/signup. The client reads STOPHY_API_KEY, or you pass it in with Stophy(api_key="st_...").

Option Default What it does
api_key STOPHY_API_KEY Your API key
base_url STOPHY_BASE_URL, or the Stophy API The server to call
max_retries 2 Retries per request. 0 turns retries off.
timeout 70.0 Time limit in seconds for each attempt

Errors and retries

API failures and malformed JSON responses raise a StophyError, which you import from stophy. It has code, retryable, retry_after_seconds, status, request_id, details and outcome_unknown. The message is str(error), and it says what went wrong and what to do next. Network and transport failures keep their original httpx.TransportError type, such as httpx.ReadTimeout or httpx.ConnectError. Invalid response compression keeps its httpx.DecodingError type. These exceptions are not wrapped in StophyError.

The SDK retries eligible reads and writes. If a write may have run and the SDK cannot safely replay it, the SDK stops and sets outcome_unknown to True on the exception, even if the API marked it retryable. This also applies to a malformed successful response. Check whether the work finished before sending a new request. On an httpx exception, use getattr(error, "outcome_unknown", False) because the attribute is only added when needed. If an HTTP retry would require waiting more than 60 seconds, the SDK raises StophyError with retry_after_seconds set.

If a keyed request remains unresolved after a lost reply, an ambiguous HTTP failure such as a gateway 502/504, invalid response compression, or a malformed successful response, its original key is available in StophyError.details["idempotencyKey"] or the httpx exception's idempotency_key attribute. A later failure, including a rate limit, keeps that recovery key. To recover, send the same body with that idempotency_key; a new call without it generates a fresh key and may duplicate the work. This also works with parsed(..., idempotency_key=key) and AsyncStophy. Invalid Retry-After headers are ignored in favor of the normal retry delay.

Docs

License

MIT

Metadata

Release files for stophy 1.4.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stophy 1.4.2
File Size Uploaded Provenance Actions
stophy-1.4.2.tar.gz 32.6 kB With provenance Details for stophy-1.4.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for stophy 1.4.2
File Interpreter ABI Platform Actions
stophy-1.4.2-py3-none-any.whl Python 3 none any Details for stophy-1.4.2-py3-none-any.whl

Total release size: 53.7 kB

Release files / stophy-1.4.2.tar.gz

Download URL stophy-1.4.2.tar.gz
Size 32.6 kB
Tags Source
SHA-256 checksum
How to use checksums
24eeb6c80cdaeb32fdd38c1d7c49094b495713bbc982942684d239538e42e58f
BLAKE2b-256 checksum
How to use checksums
cc3177d1b32f44a5314c96b5ae439425d8cb6ba40c0216c378a563274ae8d8e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / stophy-1.4.2-py3-none-any.whl

Download URL stophy-1.4.2-py3-none-any.whl
Size 21.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ae362a40b2af4b38876a785dc7b7b1231d40aaf2b84c4817cd1099706babe0a
BLAKE2b-256 checksum
How to use checksums
1d4e158a7f266aac29d30e2abaf25058c5a6f9f36258da1dca312429623302e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Security for stophy 1.4.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for stophy-1.4.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page