reader-py
Python SDK for the Reader API — content extraction for LLMs. Wraps POST /v1/read, parses responses into Pydantic models, raises typed exceptions, and auto-polls async jobs to completion.
Version: 0.2.0 · Python: 3.9+
Install
pip install reader-py
Quick start (sync)
import os
from reader_py import ReaderClient
reader = ReaderClient(api_key=os.environ["READER_KEY"])
result = reader.read(url="https://example.com")
if result.kind == "scrape":
print(result.data.markdown)
Quick start (async)
import asyncio
import os
from reader_py import AsyncReaderClient
async def main():
async with AsyncReaderClient(api_key=os.environ["READER_KEY"]) as reader:
result = await reader.read(url="https://example.com")
if result.kind == "scrape":
print(result.data.markdown)
asyncio.run(main())
reader.read(...) returns a discriminated union (Pydantic):
ScrapeReadResult(kind="scrape", data=ScrapeResult)— single-URL requests, returned immediatelyJobReadResult(kind="job", data=Job)— batch and crawl requests, auto-polled to completion
Features
- Sync and async clients —
ReaderClient(blocking, backed byhttpx.Client) andAsyncReaderClient(backed byhttpx.AsyncClient). Same method surface. - Typed errors for all 11 Reader error codes.
InsufficientCreditsError,RateLimitedError,UrlBlockedError,ScrapeTimeoutError, and more. Each subclass exposes the relevant fields (e.g.err.required,err.retry_after_seconds). - Automatic retries with exponential backoff for transient codes. Honors the
Retry-Afterheader on 429. - Pagination-aware job collection.
wait_for_job()returns the full job with every page result. - SSE streaming.
for event in reader.stream(job_id)(sync) orasync for(async) yieldsProgressEvent/PageEvent/ErrorEvent/DoneEvent. - Pydantic models everywhere — all responses are parsed into typed models with IDE autocomplete.
- Request ID tracing. Every error carries the
x-request-idheader value onerr.request_idfor support tickets.
Browser Sessions
Launch a stealthed Chrome and connect Playwright:
session = reader.sessions.create()
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.connect_over_cdp(session.ws_endpoint)
page = browser.contexts[0].new_page()
page.goto("https://example.com")
print(page.title())
browser.close()
reader.sessions.stop(session.session_id)
Async:
session = await reader.sessions.create()
# ... use async playwright ...
await reader.sessions.stop(session.session_id)
Methods: reader.sessions.create(), .get(id), .stop(id), .list()
Errors
from reader_py import (
ReaderApiError,
InsufficientCreditsError,
RateLimitedError,
UrlBlockedError,
)
try:
reader.read(url=url)
except InsufficientCreditsError as err:
print(f"Need {err.required}, have {err.available}")
except RateLimitedError as err:
print(f"Retry after {err.retry_after_seconds}s")
except UrlBlockedError as err:
print(f"Blocked: {err.reason}")
except ReaderApiError as err:
print(f"[{err.code}] {err} — see {err.docs_url}")
ReaderError is re-exported as an alias for ReaderApiError so code written against the 0.1 SDK continues to work. New code should use ReaderApiError.
Full catalog of error codes: https://reader.dev/docs/home/concepts/errors
Links
- Docs: https://reader.dev/docs
- SDK reference: https://reader.dev/docs/sdk/python
- API reference: https://reader.dev/docs/api-reference/read
- Discord: https://discord.gg/6tjkq7J5WV
Development
python -m venv .venv && source .venv/bin/activate
pip install -e .[dev]
pytest
Metadata
Release files for reader-py 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| reader_py-0.4.0.tar.gz | 14.5 kB | Without provenance | Details for reader_py-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| reader_py-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for reader_py-0.4.0-py3-none-any.whl |
Total release size: 29.6 kB
Release files / reader_py-0.4.0.tar.gz
| Download URL | reader_py-0.4.0.tar.gz |
|---|---|
| Size | 14.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f1e390149d02a90c5cfa375e81be590691cfea411a3c46697da81d111400a817
|
|
BLAKE2b-256 checksum How to use checksums |
e08809a99112498c20c5cf273a4afc83d6207c02e758631afce57e657b95e2e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / reader_py-0.4.0-py3-none-any.whl
| Download URL | reader_py-0.4.0-py3-none-any.whl |
|---|---|
| Size | 15.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aab3b6c80f18de7581099fa91365af40ce1bcc798f76c49c0c0fed6f461bd76f
|
|
BLAKE2b-256 checksum How to use checksums |
23dfaf9de7f43453e09e3fb85fc25ca1c2f18e7771af473595491b36165c4689
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Security for reader-py 0.4.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.