This walks a Python 3.10+ developer through install, init, one REST call with the agentic envelope, a real-time stream, a webhook receiver, and how the SDK behaves on errors. Expect about five minutes end-to-end.Documentation Index
Fetch the complete documentation index at: https://developer.alterscope.org/llms.txt
Use this file to discover all available pages before exploring further.
The Python SDK is published as
alterscope on PyPI at version 2.0.1. It is generated from services/risk-api/docs/openapi.yaml so the typed client and the API reference stay in lockstep.1. Install
httpx and ships behind an extras flag:
2. Initialize the client
sk_live_…. The constructor raises ValueError if api_key is missing.
3. Your first call
The cheapest “is it working?” call is an oracle classification — it always returns a shape that includes the agentic envelope (freshness, confidence, quality verdict) so you can confirm the SDK is wired correctly in one call.freshness_status_of() returns one of "realtime", "fresh", "stale", or "unknown". Treat stale as a soft-error in your agent loop — re-fetch before acting on the data.
Async client
4. Stream events
Risk events are pushed over a WebSocket. The Python SDK does not yet wrap WebSockets — use thewebsockets package directly.
factor_update (channel factors), alert_triggered (alerts), position_update (positions), apy_update (apy), market_event (events — subtypes include oracle_failure, exploit, upgrade, governance, liquidity_crunch). Full protocol reference: WebSockets API.
A typed
client.risk_events.subscribe(...) wrapper is on the SDK roadmap — track via the changelog.5. Receive a webhook
Create the webhook subscription via the SDK, then mount a handler that parses the body:Errors and retries
The SDK retries429 and connection-level failures up to max_retries times with exponential backoff (capped at 60s) and honors Retry-After on 429. Defaults: max_retries = 3, timeout = 30 seconds.
ForbiddenError, ValidationError, ServerError, plus the base AlterscopeError.
Reference
- Full SDK source + issues: github.com/alterscope/alterscope-python
- Runnable example used to verify this guide:
sdks/python/examples/quickstart.py - Provenance: every release ships a
PROVENANCE.mdwith the OpenAPI SHA-256 it was generated from.
Next steps
Pricing & quotas
Free, Pro, Pro+, and Enterprise tiers — what each gets you.
Changelog
What changed in the API and SDKs, week by week.
API Reference
Every operation with try-it-out.
Recipes
End-to-end flows: depeg detection, scoring, treasury automation.