Registry / payments / polar-sdk

polar-sdk

JSON →
library0.31.7pypypi✓ verified 83d ago

The `polar-sdk` is the official Python client for the Polar API, designed to help developers integrate subscription and monetization features into their applications. It provides access to resources like products, subscriptions, and webhooks. As of version 0.31.3, it offers both synchronous and asynchronous interfaces and is actively maintained with frequent updates.

pip install polar-sdk
INSTALL
IMPORT
SIG · POLAR-SDK
P
polar-sdk
paymentspythonv0.31.7
Install
7.0s avg
Import
Disk
44MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.31.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 45MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 7.0s · import 0.000s · 45MB
44MB installed
● package 44MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Polar
from polar_sdk import Polar
from polar import Polar

This quickstart demonstrates how to initialize the `Polar` client, fetch a list of subscriptions, and handle potential API errors. It uses an asynchronous client, which is recommended for modern Python applications. Ensure you have `POLAR_API_KEY` set in your environment or replace the placeholder with your actual API key.

import os from polar import Polar from polar.exceptions import PolarError # Initialize the Polar client. It automatically uses the POLAR_API_KEY # environment variable if set. Otherwise, you can pass it directly. # For testing, you might use a dummy key if not interacting with a live API. client = Polar(auth=os.environ.get("POLAR_API_KEY", "sk_test_..._your_key")) async def main(): try: # Example: List subscriptions (using the async client) print("Attempting to list subscriptions...") subscriptions_page = await client.subscriptions.list(limit=5) if subscriptions_page.items: print(f"Found {len(subscriptions_page.items)} subscriptions:") for sub in subscriptions_page.items: print(f" - ID: {sub.id}, Status: {sub.status}, Product ID: {sub.product_id}") else: print("No subscriptions found.") except PolarError as e: print(f"Polar API Error: {e.status_code} - {e.body}") except Exception as e: print(f"An unexpected error occurred: {e}") if __name__ == "__main__": # For running async code in a sync context (e.g., top-level script) import asyncio asyncio.run(main())
Debug
Known issues
gotchaThe SDK provides both synchronous and asynchronous clients. The default `Polar()` initialization returns a synchronous client. If you intend to use `await` with methods like `client.subscriptions.list()`, you must explicitly use `Polar(is_async=True)` and run it within an `async` function.
fix
For async usage: `client = Polar(auth=..., is_async=True)` and call methods with `await`. For sync usage: `client = Polar(auth=...)` (default) and call methods directly without `await`.
affects: >=0.1.0
gotchaAuthentication is mandatory for most API calls. The client attempts to read `POLAR_API_KEY` from environment variables. If it's not set, or you need to use a different key, you must pass it via the `auth` parameter during client initialization.
fix
Ensure `export POLAR_API_KEY='your_secret_key'` is set in your shell, or initialize with `client = Polar(auth='your_secret_key')`.
affects: >=0.1.0
gotchaError handling for API-specific issues should explicitly catch `polar.exceptions.PolarError`. This allows you to differentiate between network issues, bad requests, or other API-reported problems based on `status_code` and `body` attributes.
fix
Wrap API calls in a `try...except PolarError as e:` block to handle API responses gracefully.
affects: >=0.1.0
breakingPrior to version 0.1.0, the SDK had a different structure and import paths. The 0.1.0 release introduced a complete rewrite to a modern API client generation, making it incompatible with older versions.
fix
Upgrade to the latest version (`pip install --upgrade polar-sdk`) and refactor code according to the new client structure and import paths (e.g., `from polar import Polar`).
affects: <0.1.0
Upgrade
Version history
0.31.7latest on PyPI · released Jun 12, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
39 hits · last 30 days
node
36
Bingbot
1
Resources
polar-sdk — pip install polar-sdk · libregistry