Rayon Python SDK
Synchronous and asynchronous Python clients for RayonAPI Shape header generation and account usage. Requires Python 3.10+. Keep your API key on your server.
Documentation · Examples · Releases
Install
python -m pip install 'rayon-sdk-py>=1,<2'
Generate headers
Prepare shape.json with the required raw protection JavaScript in execution order, including
loaders and payloads where used. Include their context URLs, a current browser profile,
JavaScript-visible cookies (document_cookie) and the exact target URL, method, content type
and body string. See
material preparation and
profiles and sessions.
The SDK and API use URLs as context; they do not download scripts or send the target request.
import json
import os
from pathlib import Path
from rayon_sdk_py import Client, ShapeRequest
shape: ShapeRequest = json.loads(Path("shape.json").read_text(encoding="utf-8"))
with Client(os.environ["RAYON_API_KEY"], timeout=45) as client:
result = client.generate(shape)
target_headers = dict(result.headers)
print(result.request_id)
Apply all six target_headers to that exact request using your own target client and session.
Keep its browser identity consistent with result.profile_used and retain the session's cookies.
The response also includes generation_ms, material_ref and material_expires_at;
it does not return target cookies or verify target acceptance.
Supply exactly one of scripts or a server-issued material_ref with its original source_url.
All four request fields are required; GET/HEAD use content_type=None, body=None.
Preserve body whitespace and encoding. Persistent clients reuse unexpired material references,
while each call generates fresh headers from the supplied profile, request and cookies.
If a cached reference fails, use a fresh client with the saved scripts.
Clients and errors
The SDK authenticates with Authorization: Bearer <API key> and defaults to
https://api.rayonapi.com with a 45-second API request timeout.
AsyncClient supports async with, await client.generate(shape) and await client.usage().
client.usage() reads account usage; generate(shape, api_key) is a one-shot helper.
Errors inherit RayonError: ValidationError for invalid input, TransportError for network
failures/timeouts, HTTPError for API failures and InvalidResponseError for invalid responses.
HTTP errors expose sanitized status_code, request_id, code and retry_after.
No automatic retries. A client timeout may occur after successful generation; check history before retrying.
See the API reference and errors.
Metadata
Release files for rayon-sdk-py 1.0.3
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 | |
|---|---|---|---|---|
| rayon_sdk_py-1.0.3.tar.gz | 19.8 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rayon_sdk_py-1.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.6 kB
Release files / rayon_sdk_py-1.0.3.tar.gz
| Download URL | rayon_sdk_py-1.0.3.tar.gz |
|---|---|
| Size | 19.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
94c145e029e39068fc6f540786a01280233de4f5726ead78a558b537897f77f3
|
|
BLAKE2b-256 checksum How to use checksums |
56082e22c6f3a68209e6883eb628ae5637e7cfd0d2aeff01144a901f85d99b3b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 14, 2026.
Transparency logRelease files / rayon_sdk_py-1.0.3-py3-none-any.whl
| Download URL | rayon_sdk_py-1.0.3-py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4e1e0cd2b41c40c279d95b2f13aaf436edca1c6760e5e7b8f025d26e05e8e595
|
|
BLAKE2b-256 checksum How to use checksums |
f006dcfc0a38f54cf852f1bf8a1c27090b770a4c707e212bfbd02bd434f9658e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 14, 2026.
Transparency logSecurity for rayon-sdk-py 1.0.3
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
All 2 files in this release have been uploaded with provenance metadata.
Attestation for rayon_sdk_py-1.0.3.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 Oct 14, 2026.
Transparency logA 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.