TopGit
GitHub Repo Review

Stripe Python Library: Official SDK for the Stripe API

stripe/stripe-python
STopGit review image for stripe/stripe-python
Review by Topgit.dev for stripe/stripe-python, with GitHub repository stats and README context.
Quick verdict

Stripe Python Library is Stripe's official Python SDK for the Stripe API, installed via pip. It wraps Stripe's HTTP endpoints in typed resource classes, retries failed requests automatically with idempotency keys, and ships both a sync and async client. Reach for it the moment you're handling payments in a Python app, since writing your own wrapper rarely beats it. Skip it if your project is stuck on Python 3.8 or earlier, since 3.9+ is required.

Stars
★ 2.0k
Forks
⑂ 533
Language
Python
License
MIT
Topic
Updated
Aug 2026
Homepage
GitHub

Accessing the Stripe API with Python

Stripe Python Library is a Python package that gives applications access to the Stripe API without hand-rolling HTTP requests. It ships pre-defined classes for resources, like customers and charges, that initialize dynamically from whatever the API returns, which keeps it compatible across many Stripe API versions per the README. Configure it with a secret key from your Stripe Dashboard, then call resource methods through `StripeClient`.

Key Capabilities of the SDK

  • A `StripeClient` class, introduced in v8, that groups API calls under one configured object, replacing the older global `stripe.api_key` pattern the README says will eventually be deprecated.
  • Typed resource classes generated from API responses, so a `Customer` or `Charge` object initializes its own fields dynamically instead of you parsing raw JSON.
  • Async support: any request method works with an `_async` suffix, like `retrieve_async`, backed by `httpx` by default instead of the sync client's `requests`.
  • Automatic retries via `max_network_retries`, triggered by connection errors, timeouts, and HTTP 409 responses, with idempotency keys generated automatically so retries stay safe.
  • Swappable HTTP backends: `requests`, `httpx`, `aiohttp`, `pycurl`, or `urllib`, set through the `http_client` option on `StripeClient`.
  • Per-request overrides for API key, connected account, and Stripe API version via an `options` argument, useful for Connect platforms handling multiple accounts.
  • Type annotations since v7.1.0, tested against Pyright, with experimental support for `Unpack[TypedDict]` in MyPy.
  • Built-in request logging through the `STRIPE_LOG` environment variable or Python's own `logging` module, plus access to raw response codes and headers via `last_response`.
How this repository's GitHub stars have grown over time. Source: star-history.com.View the star history

Getting Started: Installation

Install it from PyPI with `pip install --upgrade stripe`, or build from source with `python -m pip install .`. The README lists Python 3.9+ as the supported baseline under Stripe's Language Version Support Policy; Python 2.7 support ended after version 5.5.0, and versions from 6.0.0 onward dropped it entirely. If you plan to use the async client without already having an async HTTP library installed, `pip install stripe[async]` pulls one in, a feature the README notes as new in v13.0.1. Preview features are available through separate version suffixes: `bX` for public preview (e.g. `12.2.0b2`) and `aX` for private preview, both installed by pinning the exact version with `pip install stripe==<version>`.

Making API Calls with Python

Set your secret key and call resources through `StripeClient`: `client = StripeClient("sk_test_...")`, then `client.v1.customers.list()` or `client.v1.customers.retrieve("cus_123456789")`. Failed requests raise exceptions whose class indicates the error type, per the API Reference the README links to. For async code, add `_async` to the method name, e.g. `await client.v1.customers.retrieve_async("cus_xyz")`, and `.auto_paging_iter()` works with both sync and async iteration. You can also bypass the library's method definitions entirely with `client.raw_request("post", "/v1/beta_endpoint", ...)`, available since v11, for hitting undocumented or beta endpoints directly.

Strengths

  • Published and maintained by Stripe itself, so it tracks the API's own resources and versioning rather than being a third-party reverse-engineered client.
  • Automatic retries with auto-generated idempotency keys mean transient network failures don't risk creating duplicate charges.
  • Both sync and async clients are supported natively, with the HTTP backend swappable between `requests`, `httpx`, `aiohttp`, `pycurl`, and `urllib`.
  • Type annotations, available since v7.1.0, work with Pyright out of the box, catching resource-field typos before you hit the API.
  • MIT licensed, so there are no license-compatibility questions for commercial use.

Considerations and Constraints

  • The legacy global pattern (`stripe.api_key = ...`) still works, but the README says it will be marked deprecated soon, so new projects following current docs need to learn `StripeClient` instead of the older examples still floating around online.
  • Type annotations aren't covered by semantic versioning; the README warns a minor version bump can produce new type-checker errors even though runtime behavior didn't change.
  • Telemetry about request latency and feature usage is sent to Stripe by default. You have to explicitly set `stripe.enable_telemetry = False` to turn it off.
  • Public and private preview SDKs, the `bX`/`aX` version suffixes, can introduce breaking changes between two preview versions without a major version bump, per the README, so pinning exact versions matters if you use them.
  • The README notes that the project isn't currently taking pull requests from people contributing for the first time, which limits how you can get involved beyond filing issues.

Other Ways to Integrate Stripe

stripe-ruby — Stripe's official SDK for Ruby, already reviewed on TopGit, for teams building on Rails instead of Python.stripe-ios — Stripe's official SDK for native iOS apps, already on TopGit, for integrations that live on mobile rather than a Python backend.requests + raw HTTP calls — hand-rolling calls to the Stripe REST API with a generic HTTP library, if you want to avoid depending on Stripe's typed resource classes.PayPal Python SDK — a Python client for a different payment processor, worth a look if you're not committed to Stripe specifically.

Stripe Python Library FAQ

What Python versions does stripe-python support?

Stripe Python Library supports Python 3.9 and newer under Stripe's Language Version Support Policy. Python 2.7 support ended after version 5.5.0, with 2.7 fully dropped starting in version 6.0.0.

How do I handle errors with the Stripe Python library?

Stripe Python Library raises an exception for every unsuccessful request, and the exception's class identifies the type of error that occurred. The README points to Stripe's API error-handling reference for the full list of exception classes to catch.

Can I use the Stripe Python library for asynchronous operations?

Stripe Python Library supports asynchronous operations through method names suffixed with `_async`, such as `retrieve_async`. It uses `httpx` as the default HTTP client for async requests, while synchronous requests default to `requests`.

How do I configure a proxy for Stripe Python requests?

Stripe Python Library accepts a `proxy` option on `StripeClient`, for example `StripeClient("sk_test_...", proxy="https://user:[email protected]:1234")`. This routes every request from that client through the given proxy URL.

Does the Stripe Python library send telemetry data?

Stripe Python Library sends telemetry to Stripe by default, covering request latency and feature usage, which the README says helps Stripe improve API performance overall. Setting `stripe.enable_telemetry = False` turns it off.

What is the license for the Stripe Python library?

Stripe Python Library is released under the MIT license, as listed on its GitHub repository.

The problem it solves

Calling the Stripe API directly from Python means building your own HTTP client: signing requests, parsing JSON into usable objects, retrying failed calls safely, and keeping up with a versioned API that changes over time. That's real work to redo on every project. Stripe Python Library exists so Python developers don't have to. Per the README, its resource objects build their own fields from whatever the API sends back, which is what keeps the library working across different Stripe API versions without you rewriting client code each time Stripe ships changes.

Best use cases

  • Building a Django or Flask backend that creates customers, charges, or subscriptions through the Stripe API without writing raw HTTP request code.
  • Adding async payment processing to an asyncio-based service, using the `_async` method suffix and the `httpx`-backed async client.
  • Running on a Connect platform that needs to make API calls on behalf of connected accounts, using the per-request `stripe_account` option.
  • Testing preview API features early by installing a `bX` (public preview) or `aX` (private preview) version pinned to an exact release.
  • Debugging integration issues by turning on `STRIPE_LOG=debug` or reading `last_response.code` and `last_response.headers` off any returned resource.

Who should try it — and who should skip

Try Stripe Python Library if you're building a Python application, in Django, Flask, FastAPI, or a plain script, that needs to create charges, manage customers, or handle subscriptions through Stripe's API; the typed resources and built-in retry logic save you from rebuilding that plumbing. Skip it if your project is still on Python 3.8 or older, since the README requires 3.9+, or if you specifically need the Ruby or iOS SDKs; check stripe-ruby or stripe-ios instead.

Related repositories

Source & attribution

Facts sourced from the stripe/stripe-python GitHub repository and its README.

GitHub data · last synced Aug 14, 2026Reviewed by Henry
Back to TopGit

Want a second opinion on stripe-python?

Ask an AI that can read this page — one click and you get its take on stripe-python.

GitHub