Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Polar Python SDK

The official Python client for the Polar API.

Installation

The SDK requires Python 3.11 or later.

uv add polar-sdk

or, with pip:

pip install polar-sdk

Quick Start

Create an organization access token and use the client for the current API version:

from polar.v2026_04 import Polar

polar = Polar("polar_oat_xxx")

customer_state = polar.customers.get_state_external("customer_external_id")
print(customer_state)

The client uses the production environment by default. To use the sandbox, pass environment="sandbox" when creating the client. Sandbox and production access tokens are separate.

Keep organization access tokens on the server and never expose them in browser or client-side code.

Webhooks

Use validate_event to verify that a webhook was sent by Polar and parse it into a typed payload for the selected API version. Pass the raw request body, the request headers, and your webhook signing secret:

import os

from fastapi import FastAPI, HTTPException, Request

from polar.v2026_04.webhooks import (
    PolarWebhookError,
    PolarWebhookVerificationError,
    validate_event,
)

app = FastAPI()
webhook_secret = os.environ["POLAR_WEBHOOK_SECRET"]


@app.post("/webhooks/polar")
async def polar_webhook(request: Request) -> dict[str, bool]:
    try:
        event = validate_event(
            await request.body(),
            dict(request.headers),
            webhook_secret,
        )
    except PolarWebhookVerificationError as exc:
        raise HTTPException(status_code=403, detail="Invalid webhook signature") from exc
    except PolarWebhookError as exc:
        raise HTTPException(status_code=400, detail="Invalid webhook payload") from exc

    if event.type == "order.created":
        print(event.data.id)

    return {"received": True}

The signature is checked before the body is parsed. validate_event raises PolarWebhookVerificationError for invalid signatures and PolarWebhookUnknownTypeError when the event is not supported by the selected API version. Both inherit from PolarWebhookError.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polar_sdk-1.0.0a12.tar.gz (112.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

polar_sdk-1.0.0a12-py3-none-any.whl (136.8 kB view details)

Uploaded Python 3

File details

Details for the file polar_sdk-1.0.0a12.tar.gz.

File metadata

  • Download URL: polar_sdk-1.0.0a12.tar.gz
  • Upload date:
  • Size: 112.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for polar_sdk-1.0.0a12.tar.gz
Algorithm Hash digest
SHA256 84e1f32e482afed1fa3555b2beb04dec9a7d0dbdff0b1a68b842a10d36966c1f
MD5 48b23ab9a19c54efac87bfffd142044a
BLAKE2b-256 3e6baeaa2c1db9270c0e3f421439e01967271007c7533bd5e9ad78505607cb07

See more details on using hashes here.

File details

Details for the file polar_sdk-1.0.0a12-py3-none-any.whl.

File metadata

  • Download URL: polar_sdk-1.0.0a12-py3-none-any.whl
  • Upload date:
  • Size: 136.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for polar_sdk-1.0.0a12-py3-none-any.whl
Algorithm Hash digest
SHA256 4a353c1f709c6f27a22a3db0217acb71ca489ec624367c0b3b3736dfef455647
MD5 8ed0c735ec7f5d2f2c70d6be572594c4
BLAKE2b-256 7ea84e6b4b0c707eb83669a275786309262187f1f4123b01b38d67e4f4779881

See more details on using hashes here.

Release history Release notifications | RSS feed

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page