Skip to main content
The Python SDK source is part of the Ledger repository. It is not published to PyPI or publicly distributed yet. Use the cURL quickstart for a runnable public integration. The API reference includes a Python SDK source example for every endpoint.

Install from a source checkout

If you have access to the Ledger source repository, install the package from its folder:
The package uses Python 3.9+ and the standard library for HTTP; it does not add runtime dependencies. Keep your API key on your server. The key selects the environment: ledger_test_ accesses Sandbox and ledger_live_ accesses Live. Use the same client methods for either environment and keep the keys in separate server-side variables. See Sandbox and live environments.
Python methods use snake_case names and arguments. The client sends Ledger’s documented JSON field names, including request_id for usage tracking. Each method returns the parsed JSON response as a dictionary.

Handle an API error

LedgerAPIError exposes status, code, and the parsed response body. Connection failures raise LedgerConnectionError. For plan upgrades, reuse one idempotency_key for retries of the same intended upgrade. The API reference provides cURL, Python, and TypeScript examples for the exact body and responses of each endpoint.