Stripe Python

Official Python bindings for the Stripe API, covering payments, billing, and Connect.

SDK
PyPI
v15.6.1
2,041stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
92/100Excellent
Development Activity92
Maintenance96
Community80
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
85/100Excellent
Architecture88
Code Quality92
Innovation78
Learning Curve80

The stripe Python package is Stripe’s officially maintained client library for accessing the Stripe API from Python applications. It ships a typed StripeClient with sync and async request methods, pre-built resource classes for every API object (customers, charges, subscriptions, Connect accounts, and more), and automatic handling of retries, idempotency keys, and pagination.

Beyond simple request wrapping, the library tracks Stripe’s frequent API changes closely: it is regenerated from Stripe’s OpenAPI spec, supports pinning specific API versions per request, and exposes both the stable v1 surface and newer v2 event/thin-object APIs. It is the reference implementation most Python teams reach for when integrating payments, subscription billing, or marketplace payouts with Stripe.

What You Get

  • A StripeClient class exposing every Stripe API resource (customers, charges, subscriptions, invoices, Connect accounts, and dozens more) as typed methods
  • Both synchronous and _async-suffixed asynchronous variants of every request method, backed by requests or httpx/aiohttp
  • Automatic idempotency-key generation and configurable automatic retries for transient network and 409 conflict errors
  • Built-in pagination via .auto_paging_iter() for both sync and async iteration over list endpoints
  • Type annotations (including Unpack[TypedDict] param typing) validated against Pyright, plus a raw_request escape hatch for undocumented or beta endpoints
  • Webhook signature verification and event-notification handler helpers for processing Stripe webhooks safely

Common Use Cases

  • Charging customers and processing one-off or recurring payments from a Python backend
  • Managing subscription billing lifecycles: creating plans, upgrading/downgrading, prorating, and handling invoices
  • Building a Stripe Connect marketplace or platform that onboards sellers and splits payments
  • Verifying and reacting to Stripe webhook events (e.g. invoice.paid, charge.refunded) inside a Django/Flask/FastAPI app
  • Calling in-preview or undocumented Stripe endpoints via raw_request before they land in the typed SDK surface

Under The Hood

Architecture The library centers on _api_requestor.py, which builds and signs HTTP requests, and a generated resource layer (stripe/_customer.py, _charge.py, _subscription.py, etc., plus per-resource *_service.py files) that the newer StripeClient composes into a namespaced client.v1.<resource> surface, while a legacy global-config pattern (stripe.api_key = ...) remains for backward compatibility. Sync and async code paths are generated in parallel (retrieve / retrieve_async), and cross-cutting concerns like retries, idempotency-key injection, and pagination (auto_paging_iter) live in shared request-handling code rather than per-resource, so most of the surface area is machine-generated from Stripe’s OpenAPI spec with a comparatively small hand-written core (requestor, HTTP client abstraction, error hierarchy).

Tech Stack Written in modern typed Python (3.9+), using typing_extensions for Unpack[TypedDict]-based keyword-argument typing checked against Pyright, requests as the default synchronous HTTP client with pluggable alternatives (httpx, aiohttp, pycurl, urllib), and flit_core as the build backend. Ruff handles linting and formatting, and the project uses just as a task runner wrapping a mise/pyenv-managed virtualenv; CI (GitHub Actions) runs static checks, mypy/pyright type-checking, and a build/test matrix.

Code Quality The repo ships an extensive test suite (60+ test_*.py files under tests/, including generated-example tests, integration tests, and dedicated tests for error handling, request options, and the HTTP client abstraction) that runs against stripe-mock rather than the live API. Errors are modeled as an explicit typed exception hierarchy (StripeError and subclasses in _error.py) carrying HTTP status, body, and Stripe request ID rather than being swallowed, naming is consistent and machine-generated across resources, and CI enforces linting (Ruff), formatting, and strict type-checking (Pyright/mypy) on every change.

What Makes It Unique Unlike a typical REST client, this SDK is regenerated from Stripe’s own OpenAPI specification, keeping its typed surface tightly synchronized with a very large and fast-moving API (open enum types anticipate values Stripe may add later without breaking type checks). It uniquely runs sync and async code from the same generated definitions, exposes a raw_request/beta-version mechanism for calling undocumented or preview endpoints before they’re formally typed, and supports per-request API-version pinning so callers can control exactly which Stripe API version a given call targets independent of the installed SDK version.

Used by 13 apps in this directory

TypeScript
60%
Other

agenta

Developer Tools · Devops · AI Development

4,706

The open-source LLMOps platform unifying prompt engineering, evaluation, and observability for teams building reliable LLM applications.

View details
91
Repo Health
77
Technical
67
Dependency
Built with
TypeScript60%
Python38%
Updated yesterday
Python
67%
Other

AutoGPT

Automation · Productivity · AI Assistants

187,177

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
66
Dependency
Built with
Python67%
TypeScript32%
Updated today
TypeScript
71%
Other

highlight.io

Developer Tools · Analytics · Monitoring

9,372

Open-source full-stack monitoring that unifies session replay, error tracking, logging, and distributed tracing so you can stop context-switching between tools.

View details
69
Repo Health
78
Technical
65
Dependency
Built with
TypeScript71%
Go16%
Updated 2 weeks ago
Python
51%
AGPL 3.0

Khoj

AI Assistants · Knowledge Management · Productivity

37,160

A self-hostable AI second brain that chats with your documents, searches the web, builds custom agents, and runs entirely on your own LLM.

View details
75
Repo Health
82
Technical
69
Dependency
Built with
Python51%
TypeScript36%
Updated 1 months ago
Python
85%
Apache 2.0

knowhere

AI Development · Developer Tools

2,942

Transform messy, unstructured documents into persistent, navigable memory that AI agents can actually use.

View details
83
Repo Health
75
Technical
69
Dependency
Built with
Python85%
HTML15%
Updated yesterday
Python
51%
AGPL 3.0

LearnHouse

Learning Management · CMS

2,240

Open-source LMS with AI tutoring, real-time collaboration boards, live code execution, and built-in course monetization — self-hosted in minutes.

View details
90
Repo Health
77
Technical
66
Dependency
Built with
Python51%
TypeScript48%
Updated yesterday
Python
67%
Other

Morphik

AI Development · Search · Databases

3,710

Morphik is an AI-native ingestion and retrieval engine that lets developers store, search, and reason over visually rich documents — scanned PDFs, manuals, slides, and video — without duct-taping together OCR, an embedding model, and a vector database.

View details
61
Repo Health
71
Technical
67
Dependency
Built with
Python67%
TypeScript25%
Updated 3 days ago
TypeScript
94%
Other

OpenHands

AI Code Assistants · AI Development

86,377

The self-hosted developer control center for running AI coding agents — locally, in Docker, on VMs, or across cloud backends — with automation workflows for GitHub, Slack, and more.

View details
91
Repo Health
82
Technical
70
Dependency
Built with
TypeScript94%
Updated today
TypeScript
53%
Other

Phase Console

Security · Devops

914

End-to-end encrypted secrets management for engineering teams — from local dev to Kubernetes production.

View details
83
Repo Health
73
Technical
66
Dependency
Built with
TypeScript53%
Python45%
Updated 2 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search