Official Python SDK for Syttra — clean, AI-ready web content as an API.
Project description
syttra (Python)
Official Python SDK for Syttra — the API for clean, AI-ready web content.
pip install syttra
Looking for the public REST docs? See syttra.com/docs/rest. The full SDK reference lives at syttra.com/docs/sdk/python.
Quickstart
Create an API key at syttra.com/dashboard/keys, then:
from syttra import Syttra
client = Syttra(api_key="sk_live_...")
# 1. Submit a job
job = client.create_job(url="https://en.wikipedia.org/wiki/White_House")
# 2. Wait for it to finish (polls in the background)
finished = client.wait_for_job(job.job_id)
# 3. Download the result
result = client.get_job_result(finished.job_id)
print(result.body) # markdown by default
print(result.filename) # "job-<id>.md" — ready to write to disk
The SDK reads SYTTRA_API_KEY from the environment when you don't pass api_key, so you can keep the key out of source. Syttra is a context manager — use with Syttra(...) as client: to close the connection pool deterministically.
Crawl modes
| Mode | What it does |
|---|---|
single (default) |
Crawls just the given URL. |
full |
Starts at the URL, follows same-domain links breadth-first up to max_depth / max_pages. |
select |
Crawls exactly the URLs you list — typically picked from a sitemap preview. |
from syttra import CrawlMode, Syttra
client = Syttra()
# Discover URLs first
preview = client.preview_sitemap("https://example.com")
chosen = [u for u in preview.urls if "/blog/" in u]
# Crawl just those
job = client.create_job(
url="https://example.com",
mode=CrawlMode.SELECT,
urls=chosen,
)
Errors
Every non-2xx response raises a typed exception. Catch by class instead of by status code:
from syttra import Syttra, QuotaExceeded, Unauthorized, ApiError
try:
job = client.create_job(url="https://example.com")
except QuotaExceeded as exc:
print(f"Out of pages: {exc.details}")
except Unauthorized:
print("API key revoked or wrong env (live vs test)")
except ApiError as exc:
# Generic fallback. Carries .status, .code, .message, .details, .request_id.
print(f"{exc.status} {exc.code}: {exc.message} (request_id={exc.request_id})")
request_id is what we'll ask for if you open a support ticket — copy it straight in.
Retries
The SDK retries 429 and gateway errors (502, 503, 504) up to three times with exponential backoff. Retry-After headers are honoured. Plain 500 errors are not retried by default — they usually mean an actual bug rather than transient flakiness — but you can opt in:
from syttra import RetryPolicy, Syttra
client = Syttra(
retry=RetryPolicy(
max_attempts=5,
retry_on_5xx=True,
),
)
Quota
usage = client.get_usage()
print(f"{usage.used} / {usage.quota} pages this month")
print(f"On the {usage.plan.name} plan" if usage.plan else "No plan assigned")
get_usage() is also handy as a cheap "is my key valid?" check.
What's in v0.1
- Sync client (
Syttra) covering jobs, usage, sitemap preview, and the public plans list. - Typed Pydantic v2 response models — same shapes the API itself uses.
- Structured exceptions per HTTP status (
Unauthorized,QuotaExceeded, …). - Automatic retries with exponential backoff and
Retry-Aftersupport. wait_for_jobhelper for the polling pattern.
What's coming
- Async client in v0.2 — same API,
AsyncSyttrawithawait. - OpenAPI-generated models so the SDK never lags the API.
- Dashboard surface (
/v1/account/api-keys) once we open Clerk JWT auth to non-browser callers.
Track everything on the docs site.
Development
git clone https://github.com/syttra/syttra-python && cd syttra-python
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest # runs the unit suite (no network, mocked via respx)
ruff check src/ tests/ # lint
ruff format src/ tests/ # format
mypy src/syttra # type check
Releasing follows the runbook in RUNBOOK.md.
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file syttra-0.1.0.tar.gz.
File metadata
- Download URL: syttra-0.1.0.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c39f4d8ded39452bf79ea7ddf20c8b5588dcbb429ced178fb27907a1ae605a02
|
|
| MD5 |
253a004cf7c891c257bfd59c08b11260
|
|
| BLAKE2b-256 |
b86eb716c7f0256243f9e7673c59acea817ae04b47298f9f7489adc403695da6
|
File details
Details for the file syttra-0.1.0-py3-none-any.whl.
File metadata
- Download URL: syttra-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
122462d84e758be41cea83d748e9f25177de3aef91c2fa7c75ab5a8b3bee58f5
|
|
| MD5 |
be6116d01d4bcaccc228e560e940a3cf
|
|
| BLAKE2b-256 |
5d6e137a60ef5c176e58f1dbda0005334e10198176114c1e582eec741912f11e
|