Releases: poli-page/sdk-python
Releases · poli-page/sdk-python
v0.9.0
First public release (pre-1.0). Behavior parity with @poli-page/sdk@1.0.0 (Node).
Added
PoliPagesynchronous client +AsyncPoliPageasyncio-native client, parallel surfaces backed byhttpx.Client/httpx.AsyncClient. Use either; the SDK does not auto-detect.render.*namespace:pdf(input) → bytes,pdf_stream(input)(sync / async context manager yielding chunks),preview(input) → PreviewResult,document(input) → DocumentDescriptor.render.pdfandrender.pdf_streammake two HTTP calls (POST /v1/render+GET presigned_pdf_url) — the auto-download is an SDK convenience.documents.*namespace:get(id),preview(id),thumbnails(id, options),delete(id). All{id}segments URL-encoded.DocumentDescriptor.download_pdf()(sync) /AsyncDocumentDescriptor.download_pdf()(async) — fetch PDF bytes from the descriptor'spresigned_pdf_url.- Project-mode enforcement:
render.pdf/pdf_stream/documentreject inline-shaped input withPoliPageError(code='PROJECT_REQUIRED_FOR_DOCUMENT')before the HTTP call.render.previewaccepts either mode. Type-level enforcement viaProjectModeInput/InlineModeInputTypedDicts. metadatapass-through on all render inputs; echoed verbatim onDocumentDescriptor.metadata.poli_page.fs.render_to_file+async_render_to_file— stream a PDF directly to disk; creates parent dirs, overwrites existing.- Auto-generated
Idempotency-Key(UUID4) on every POST; per-call override viaidempotency_keyin the input dict. - Retry policy: 5xx, 429, network errors, timeouts. Exponential backoff with
[0.5, 1.5)jitter; honorsRetry-AfterandRetry-After-Ms(sub-second precision wins over seconds), capped at 30 s. - Typed error hierarchy (
PoliPageErrorbase;APIConnectionError/APITimeoutError/APIStatusErrorwith per-status subclasses for 400/401/403/404/409/410/422/429/5xx). Predicate helpersis_auth_error/is_rate_limit_error/is_validation_error/is_network_error/is_retryablekept for cross-language parity. error_codesmodule with named constants for every known API code (MISSING_API_KEY,PAYMENT_REQUIRED,QUOTA_EXCEEDED, …) and reserved SDK codes (INVALID_OPTIONS,NETWORK_ERROR,TIMEOUT,ABORTED,UNKNOWN_ERROR,DOWNLOAD_FAILED).- Observability: silent-by-default
logging.getLogger('poli_page')logger driven byPOLI_PAGE_LOG=debug|info|warning|error. SDK-level hookson_retry/on_errorare sync callables; their exceptions never break the request. For request/response wiretapping, pass your ownhttpx.Clientwithevent_hooks={...}. - Env-var fallbacks mirroring
anthropic-sdk-python/openai-python:POLI_PAGE_API_KEY(constructor falls back here whenapi_key=is omitted);POLI_PAGE_BASE_URL(defaulthttps://api.poli.page). - Context-manager lifecycle:
with PoliPage(...) as client:(sync) /async with AsyncPoliPage(...) as client:(async). Sockets close deterministically. - Injected
http_client: pass a pre-configuredhttpx.Client/httpx.AsyncClientfor proxies, custom TLS, shared connection pools, or test transports. Caller-owned clients are not closed onclose()/aclose(). py.typedmarker — pyrightstrictand mypy--strictonsrc/are both green.- PyPI Trusted Publishing workflow (tag-driven) for signed-attestation releases; pushing a
vX.Y.Ztag publishes to PyPI, a manual run rehearses on TestPyPI.scripts/release.shremains a local fallback. - Runnable demos at
demo/sync_demo.pyanddemo/async_demo.py— walk every public method end-to-end against the live API; outputs are byte-equivalent across sync / async.
Contract
- Wire format: snake_case in Python, camelCase on the wire. The SDK translates at top level only — user-supplied
dataandmetadatakeys reach the wire and back verbatim. - Spec parity: same retry policy, error codes, predicates, project-mode constraint, primitive-only
RenderMetadata, thumbnails wire wrap/unwrap, anddocuments.previewtext/html +X-Document-Page-Countparsing as@poli-page/sdk@1.0.0.
Runtime requirements
- Python 3.11 or later.
httpx>=0.25,<1.0— the only runtime dependency. Nopydantic, notyping-extensions, norequests.