Name | stripe JSON |
Version |
13.0.1
JSON |
| download |
home_page | None |
Summary | Python bindings for the Stripe API |
upload_time | 2025-10-03 19:37:17 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.7 |
license | None |
keywords |
stripe
api
payments
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Stripe Python Library
[](https://pypi.python.org/pypi/stripe)
[](https://github.com/stripe/stripe-python/actions?query=branch%3Amaster)
The Stripe Python library provides convenient access to the Stripe API from
applications written in the Python language. It includes a pre-defined set of
classes for API resources that initialize themselves dynamically from API
responses which makes it compatible with a wide range of versions of the Stripe
API.
## API Documentation
See the [Python API docs](https://stripe.com/docs/api?lang=python).
## Installation
This package is available on PyPI:
```sh
pip install --upgrade stripe
```
Alternatively, install from source with:
```sh
python -m pip install .
```
### Requirements
Per our [Language Version Support Policy](https://docs.stripe.com/sdks/versioning?lang=python#stripe-sdk-language-version-support-policy), we currently support **Python 3.7+**.
Support for Python 3.7 and 3.8 is deprecated and will be removed in an upcoming major version. Read more and see the full schedule in the docs: https://docs.stripe.com/sdks/versioning?lang=python#stripe-sdk-language-version-support-policy
#### Extended Support
#### Python 2.7 deprecation
[The Python Software Foundation (PSF)](https://www.python.org/psf-landing/) community [announced the end of support of Python 2](https://www.python.org/doc/sunset-python-2/) on 01 January 2020.
Starting with version 6.0.0 Stripe SDK Python packages will no longer support Python 2.7. To continue to get new features and security updates, please make sure to update your Python runtime to Python 3.6+.
The last version of the Stripe SDK that supported Python 2.7 was **5.5.0**.
## Usage
The library needs to be configured with your account's secret key which is
available in your [Stripe Dashboard][api-keys]. Set `stripe.api_key` to its
value:
```python
from stripe import StripeClient
client = StripeClient("sk_test_...")
# list customers
customers = client.v1.customers.list()
# print the first customer's email
print(customers.data[0].email)
# retrieve specific Customer
customer = client.v1.customers.retrieve("cus_123456789")
# print that customer's email
print(customer.email)
```
### StripeClient vs legacy pattern
We introduced the `StripeClient` class in v8 of the Python SDK. The legacy pattern used prior to that version is still available to use but will be marked as deprecated soon. Review the [migration guide to use StripeClient](<https://github.com/stripe/stripe-python/wiki/Migration-guide-for-v8-(StripeClient)>) to move from the legacy pattern.
Once the legacy pattern is deprecated, new API endpoints will only be accessible in the StripeClient. While there are no current plans to remove the legacy pattern for existing API endpoints, this may change in the future.
### Handling exceptions
Unsuccessful requests raise exceptions. The class of the exception will reflect
the sort of error that occurred. Please see the [Api
Reference](https://stripe.com/docs/api/errors/handling) for a description of
the error classes you should handle, and for information on how to inspect
these errors.
### Per-request Configuration
Configure individual requests with the `options` argument. For example, you can make
requests with a specific [Stripe Version](https://stripe.com/docs/api#versioning)
or as a [connected account](https://stripe.com/docs/connect/authentication#authentication-via-the-stripe-account-header):
```python
from stripe import StripeClient
client = StripeClient("sk_test_...")
# list customers
client.v1.customers.list(
options={
"api_key": "sk_test_...",
"stripe_account": "acct_...",
"stripe_version": "2019-02-19",
}
)
# retrieve single customer
client.v1.customers.retrieve(
"cus_123456789",
options={
"api_key": "sk_test_...",
"stripe_account": "acct_...",
"stripe_version": "2019-02-19",
}
)
```
### Configuring an HTTP Client
You can configure your `StripeClient` to use `urlfetch`, `requests`, `pycurl`, or
`urllib` with the `http_client` option:
```python
client = StripeClient("sk_test_...", http_client=stripe.UrlFetchClient())
client = StripeClient("sk_test_...", http_client=stripe.RequestsClient())
client = StripeClient("sk_test_...", http_client=stripe.PycurlClient())
client = StripeClient("sk_test_...", http_client=stripe.UrllibClient())
```
Without a configured client, by default the library will attempt to load
libraries in the order above (i.e. `urlfetch` is preferred with `urllib2` used
as a last resort). We usually recommend that people use `requests`.
### Configuring a Proxy
A proxy can be configured with the `proxy` client option:
```python
client = StripeClient("sk_test_...", proxy="https://user:pass@example.com:1234")
```
### Configuring Automatic Retries
You can enable automatic retries on requests that fail due to a transient
problem by configuring the maximum number of retries:
```python
client = StripeClient("sk_test_...", max_network_retries=2)
```
Various errors can trigger a retry, like a connection error or a timeout, and
also certain API responses like HTTP status `409 Conflict`.
[Idempotency keys][idempotency-keys] are automatically generated and added to
requests, when not given, to guarantee that retries are safe.
### Logging
The library can be configured to emit logging that will give you better insight
into what it's doing. The `info` logging level is usually most appropriate for
production use, but `debug` is also available for more verbosity.
There are a few options for enabling it:
1. Set the environment variable `STRIPE_LOG` to the value `debug` or `info`
```sh
$ export STRIPE_LOG=debug
```
2. Set `stripe.log`:
```python
import stripe
stripe.log = 'debug'
```
3. Enable it through Python's logging module:
```python
import logging
logging.basicConfig()
logging.getLogger('stripe').setLevel(logging.DEBUG)
```
### Accessing response code and headers
You can access the HTTP response code and headers using the `last_response` property of the returned resource.
```python
customer = client.v1.customers.retrieve(
"cus_123456789"
)
print(customer.last_response.code)
print(customer.last_response.headers)
```
### Writing a Plugin
If you're writing a plugin that uses the library, we'd appreciate it if you
identified using `stripe.set_app_info()`:
```py
stripe.set_app_info("MyAwesomePlugin", version="1.2.34", url="https://myawesomeplugin.info")
```
This information is passed along when the library makes calls to the Stripe
API.
### Telemetry
By default, the library sends telemetry to Stripe regarding request latency and feature usage. These
numbers help Stripe improve the overall latency of its API for all users, and
improve popular features.
You can disable this behavior if you prefer:
```python
stripe.enable_telemetry = False
```
## Types
In [v7.1.0](https://github.com/stripe/stripe-python/releases/tag/v7.1.0) and
newer, the
library includes type annotations. See [the wiki](https://github.com/stripe/stripe-python/wiki/Inline-type-annotations)
for a detailed guide.
Please note that some annotations use features that were only fairly recently accepted,
such as [`Unpack[TypedDict]`](https://peps.python.org/pep-0692/#specification) that was
[accepted](https://discuss.python.org/t/pep-692-using-typeddict-for-more-precise-kwargs-typing/17314/81)
in January 2023. We have tested that these types are recognized properly by [Pyright](https://github.com/microsoft/pyright).
Support for `Unpack` in MyPy is still experimental, but appears to degrade gracefully.
Please [report an issue](https://github.com/stripe/stripe-python/issues/new/choose) if there
is anything we can do to improve the types for your type checker of choice.
### Types and the Versioning Policy
We release type changes in minor releases. While stripe-python follows semantic
versioning, our semantic versions describe the _runtime behavior_ of the
library alone. Our _type annotations are not reflected in the semantic
version_. That is, upgrading to a new minor version of stripe-python might
result in your type checker producing a type error that it didn't before. You
can use a `~=x.x` or `x.x.*` [version specifier](https://peps.python.org/pep-0440/#examples)
in your `requirements.txt` to constrain `pip` to a certain minor range of `stripe-python`.
### Types and API Versions
The types describe the [Stripe API version](https://stripe.com/docs/api/versioning)
that was the latest at the time of release. This is the version that your library
sends by default. If you are overriding `stripe.api_version` / `stripe_version` on the `StripeClient`, or using a
[webhook endpoint](https://stripe.com/docs/webhooks#api-versions) tied to an older version,
be aware that the data you see at runtime may not match the types.
### Public Preview SDKs
Stripe has features in the [public preview phase](https://docs.stripe.com/release-phases) that can be accessed via versions of this package that have the `bX` suffix like `12.2.0b2`.
We would love for you to try these as we incrementally release new features and improve them based on your feedback.
To install, pick the latest version with the `bX` suffix by reviewing the [releases page](https://github.com/stripe/stripe-python/releases/) and then use it in the `pip install` command:
```
pip install stripe==<replace-with-the-version-of-your-choice>
```
> **Note**
> There can be breaking changes between two versions of the public preview SDKs without a bump in the major version. Therefore we recommend pinning the package version to a specific version in your [pyproject.toml](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#dependencies-and-requirements) or [requirements file](https://pip.pypa.io/en/stable/user_guide/#requirements-files). This way you can install the same version each time without breaking changes unless you are intentionally looking for the latest public preview SDK.
Some preview features require a name and version to be set in the `Stripe-Version` header like `feature_beta=v3`. If your preview feature has this requirement, use the `stripe.add_beta_version` function (available only in the public preview SDKs):
```python
stripe.add_beta_version("feature_beta", "v3")
```
### Private Preview SDKs
Stripe has features in the [private preview phase](https://docs.stripe.com/release-phases) that can be accessed via versions of this package that have the `aX` suffix like `12.2.0a2`. These are invite-only features. Once invited, you can install the private preview SDKs by following the same instructions as for the [public preview SDKs](https://github.com/stripe/stripe-python?tab=readme-ov-file#public-preview-sdks) above and replacing the suffix `b` with `a` in package versions.
### Custom requests
If you would like to send a request to an undocumented API (for example you are in a private beta), or if you prefer to bypass the method definitions in the library and specify your request details directly, you can use the `raw_request` method on `StripeClient`.
```python
client = StripeClient("sk_test_...")
response = client.raw_request(
"post", "/v1/beta_endpoint", param=123, stripe_version="2022-11-15; feature_beta=v3"
)
# (Optional) response is a StripeResponse. You can use `client.deserialize` to get a StripeObject.
deserialized_resp = client.deserialize(response, api_mode='V1')
```
### Async
Asynchronous versions of request-making methods are available by suffixing the method name
with `_async`.
```python
# With StripeClient
client = StripeClient("sk_test_...")
customer = await client.v1.customers.retrieve_async("cus_xyz")
# With global client
stripe.api_key = "sk_test_..."
customer = await stripe.Customer.retrieve_async("cus_xyz")
# .auto_paging_iter() implements both AsyncIterable and Iterable
async for c in await stripe.Customer.list_async().auto_paging_iter():
...
```
There is no `.save_async` as `.save` is [deprecated since stripe-python v5](https://github.com/stripe/stripe-python/wiki/Migration-guide-for-v5#deprecated). Please migrate to `.modify_async`.
The default HTTP client uses `requests` for making synchronous requests but
`httpx` for making async requests. If you're migrating to async, we recommend
you to explicitly initialize your own http client and pass it to StripeClient
or set it as the global default.
If you don't already have a dependency on an async-compatible HTTP library, `pip install stripe[async]` will install one for you (new in `v13.0.1`).
```python
# By default, an explicitly initialized HTTPXClient will raise an exception if you
# attempt to call a sync method. If you intend to only use async, this is useful to
# make sure you don't unintentionally make a synchronous request.
my_http_client = stripe.HTTPXClient()
# If you want to use httpx to make sync requests, you can disable this
# behavior.
my_http_client = stripe.HTTPXClient(allow_sync_methods=True)
# aiohttp is also available (does not support sync requests)
my_http_client = stripe.AIOHTTPClient()
# With StripeClient
client = StripeClient("sk_test_...", http_client=my_http_client)
# With the global client
stripe.default_http_client = my_http_client
```
You can also subclass `stripe.HTTPClient` and provide your own instance.
## Support
New features and bug fixes are released on the latest major version of the Stripe Python library. If you are on an older major version, we recommend that you upgrade to the latest in order to use the new features and bug fixes including those for security vulnerabilities. Older major versions of the package will continue to be available for use, but will not be receiving any updates.
## Development
[Contribution guidelines for this project](CONTRIBUTING.md)
The test suite depends on [stripe-mock], so make sure to fetch and run it from a
background terminal ([stripe-mock's README][stripe-mock] also contains
instructions for installing via Homebrew and other methods):
```sh
go install github.com/stripe/stripe-mock@latest
stripe-mock
```
We use [just](https://github.com/casey/just) for conveniently running development tasks. You can use them directly, or copy the commands out of the `justfile`. To our help docs, run `just`. By default, all commands will use an virtualenv created by your default python version (whatever comes out of `python --version`). We recommend using [mise](https://mise.jdx.dev/lang/python.html) or [pyenv](https://github.com/pyenv/pyenv) to control that version.
Run the following command to set up the development virtualenv:
```sh
just venv
# or: python -m venv venv && venv/bin/python -I -m pip install -e .
```
Run all tests:
```sh
just test
# or: venv/bin/pytest
```
Run all tests in a single file:
```sh
just test tests/api_resources/abstract/test_updateable_api_resource.py
# or: venv/bin/pytest tests/api_resources/abstract/test_updateable_api_resource.py
```
Run a single test suite:
```sh
just test tests/api_resources/abstract/test_updateable_api_resource.py::TestUpdateableAPIResource
# or: venv/bin/pytest tests/api_resources/abstract/test_updateable_api_resource.py::TestUpdateableAPIResource
```
Run a single test:
```sh
just test tests/api_resources/abstract/test_updateable_api_resource.py::TestUpdateableAPIResource::test_save
# or: venv/bin/pytest tests/api_resources/abstract/test_updateable_api_resource.py::TestUpdateableAPIResource::test_save
```
Run the linter with:
```sh
just lint
# or: venv/bin/python -m flake8 --show-source stripe tests
```
The library uses [Ruff][ruff] for code formatting. Code must be formatted
with Black before PRs are submitted, otherwise CI will fail. Run the formatter
with:
```sh
just format
# or: venv/bin/ruff format . --quiet
```
[api-keys]: https://dashboard.stripe.com/account/apikeys
[ruff]: https://github.com/astral-sh/ruff
[connect]: https://stripe.com/connect
[poetry]: https://github.com/sdispater/poetry
[stripe-mock]: https://github.com/stripe/stripe-mock
[idempotency-keys]: https://stripe.com/docs/api/idempotent_requests?lang=python
<!--
# vim: set tw=79:
-->
Raw data
{
"_id": null,
"home_page": null,
"name": "stripe",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "stripe, api, payments",
"author": null,
"author_email": "Stripe <support@stripe.com>",
"download_url": "https://files.pythonhosted.org/packages/d8/36/edac714e44a1a0048e74cc659b6070b42dd7027473e8f9f06a727b3860b6/stripe-13.0.1.tar.gz",
"platform": null,
"description": "# Stripe Python Library\n\n[](https://pypi.python.org/pypi/stripe)\n[](https://github.com/stripe/stripe-python/actions?query=branch%3Amaster)\n\nThe Stripe Python library provides convenient access to the Stripe API from\napplications written in the Python language. It includes a pre-defined set of\nclasses for API resources that initialize themselves dynamically from API\nresponses which makes it compatible with a wide range of versions of the Stripe\nAPI.\n\n## API Documentation\n\nSee the [Python API docs](https://stripe.com/docs/api?lang=python).\n\n## Installation\n\nThis package is available on PyPI:\n\n```sh\npip install --upgrade stripe\n```\n\nAlternatively, install from source with:\n\n```sh\npython -m pip install .\n```\n\n### Requirements\n\nPer our [Language Version Support Policy](https://docs.stripe.com/sdks/versioning?lang=python#stripe-sdk-language-version-support-policy), we currently support **Python 3.7+**.\n\nSupport for Python 3.7 and 3.8 is deprecated and will be removed in an upcoming major version. Read more and see the full schedule in the docs: https://docs.stripe.com/sdks/versioning?lang=python#stripe-sdk-language-version-support-policy\n\n#### Extended Support\n\n#### Python 2.7 deprecation\n\n[The Python Software Foundation (PSF)](https://www.python.org/psf-landing/) community [announced the end of support of Python 2](https://www.python.org/doc/sunset-python-2/) on 01 January 2020.\nStarting with version 6.0.0 Stripe SDK Python packages will no longer support Python 2.7. To continue to get new features and security updates, please make sure to update your Python runtime to Python 3.6+.\n\nThe last version of the Stripe SDK that supported Python 2.7 was **5.5.0**.\n\n## Usage\n\nThe library needs to be configured with your account's secret key which is\navailable in your [Stripe Dashboard][api-keys]. Set `stripe.api_key` to its\nvalue:\n\n```python\nfrom stripe import StripeClient\n\nclient = StripeClient(\"sk_test_...\")\n\n# list customers\ncustomers = client.v1.customers.list()\n\n# print the first customer's email\nprint(customers.data[0].email)\n\n# retrieve specific Customer\ncustomer = client.v1.customers.retrieve(\"cus_123456789\")\n\n# print that customer's email\nprint(customer.email)\n```\n\n### StripeClient vs legacy pattern\n\nWe introduced the `StripeClient` class in v8 of the Python SDK. The legacy pattern used prior to that version is still available to use but will be marked as deprecated soon. Review the [migration guide to use StripeClient](<https://github.com/stripe/stripe-python/wiki/Migration-guide-for-v8-(StripeClient)>) to move from the legacy pattern.\n\nOnce the legacy pattern is deprecated, new API endpoints will only be accessible in the StripeClient. While there are no current plans to remove the legacy pattern for existing API endpoints, this may change in the future.\n\n### Handling exceptions\n\nUnsuccessful requests raise exceptions. The class of the exception will reflect\nthe sort of error that occurred. Please see the [Api\nReference](https://stripe.com/docs/api/errors/handling) for a description of\nthe error classes you should handle, and for information on how to inspect\nthese errors.\n\n### Per-request Configuration\n\nConfigure individual requests with the `options` argument. For example, you can make\nrequests with a specific [Stripe Version](https://stripe.com/docs/api#versioning)\nor as a [connected account](https://stripe.com/docs/connect/authentication#authentication-via-the-stripe-account-header):\n\n```python\nfrom stripe import StripeClient\n\nclient = StripeClient(\"sk_test_...\")\n\n# list customers\nclient.v1.customers.list(\n options={\n \"api_key\": \"sk_test_...\",\n \"stripe_account\": \"acct_...\",\n \"stripe_version\": \"2019-02-19\",\n }\n)\n\n# retrieve single customer\nclient.v1.customers.retrieve(\n \"cus_123456789\",\n options={\n \"api_key\": \"sk_test_...\",\n \"stripe_account\": \"acct_...\",\n \"stripe_version\": \"2019-02-19\",\n }\n)\n```\n\n### Configuring an HTTP Client\n\nYou can configure your `StripeClient` to use `urlfetch`, `requests`, `pycurl`, or\n`urllib` with the `http_client` option:\n\n```python\nclient = StripeClient(\"sk_test_...\", http_client=stripe.UrlFetchClient())\nclient = StripeClient(\"sk_test_...\", http_client=stripe.RequestsClient())\nclient = StripeClient(\"sk_test_...\", http_client=stripe.PycurlClient())\nclient = StripeClient(\"sk_test_...\", http_client=stripe.UrllibClient())\n```\n\nWithout a configured client, by default the library will attempt to load\nlibraries in the order above (i.e. `urlfetch` is preferred with `urllib2` used\nas a last resort). We usually recommend that people use `requests`.\n\n### Configuring a Proxy\n\nA proxy can be configured with the `proxy` client option:\n\n```python\nclient = StripeClient(\"sk_test_...\", proxy=\"https://user:pass@example.com:1234\")\n```\n\n### Configuring Automatic Retries\n\nYou can enable automatic retries on requests that fail due to a transient\nproblem by configuring the maximum number of retries:\n\n```python\nclient = StripeClient(\"sk_test_...\", max_network_retries=2)\n```\n\nVarious errors can trigger a retry, like a connection error or a timeout, and\nalso certain API responses like HTTP status `409 Conflict`.\n\n[Idempotency keys][idempotency-keys] are automatically generated and added to\nrequests, when not given, to guarantee that retries are safe.\n\n### Logging\n\nThe library can be configured to emit logging that will give you better insight\ninto what it's doing. The `info` logging level is usually most appropriate for\nproduction use, but `debug` is also available for more verbosity.\n\nThere are a few options for enabling it:\n\n1. Set the environment variable `STRIPE_LOG` to the value `debug` or `info`\n\n ```sh\n $ export STRIPE_LOG=debug\n ```\n\n2. Set `stripe.log`:\n\n ```python\n import stripe\n stripe.log = 'debug'\n ```\n\n3. Enable it through Python's logging module:\n\n ```python\n import logging\n logging.basicConfig()\n logging.getLogger('stripe').setLevel(logging.DEBUG)\n ```\n\n### Accessing response code and headers\n\nYou can access the HTTP response code and headers using the `last_response` property of the returned resource.\n\n```python\ncustomer = client.v1.customers.retrieve(\n \"cus_123456789\"\n)\n\nprint(customer.last_response.code)\nprint(customer.last_response.headers)\n```\n\n### Writing a Plugin\n\nIf you're writing a plugin that uses the library, we'd appreciate it if you\nidentified using `stripe.set_app_info()`:\n\n```py\nstripe.set_app_info(\"MyAwesomePlugin\", version=\"1.2.34\", url=\"https://myawesomeplugin.info\")\n```\n\nThis information is passed along when the library makes calls to the Stripe\nAPI.\n\n### Telemetry\n\nBy default, the library sends telemetry to Stripe regarding request latency and feature usage. These\nnumbers help Stripe improve the overall latency of its API for all users, and\nimprove popular features.\n\nYou can disable this behavior if you prefer:\n\n```python\nstripe.enable_telemetry = False\n```\n\n## Types\n\nIn [v7.1.0](https://github.com/stripe/stripe-python/releases/tag/v7.1.0) and\nnewer, the\nlibrary includes type annotations. See [the wiki](https://github.com/stripe/stripe-python/wiki/Inline-type-annotations)\nfor a detailed guide.\n\nPlease note that some annotations use features that were only fairly recently accepted,\nsuch as [`Unpack[TypedDict]`](https://peps.python.org/pep-0692/#specification) that was\n[accepted](https://discuss.python.org/t/pep-692-using-typeddict-for-more-precise-kwargs-typing/17314/81)\nin January 2023. We have tested that these types are recognized properly by [Pyright](https://github.com/microsoft/pyright).\nSupport for `Unpack` in MyPy is still experimental, but appears to degrade gracefully.\nPlease [report an issue](https://github.com/stripe/stripe-python/issues/new/choose) if there\nis anything we can do to improve the types for your type checker of choice.\n\n### Types and the Versioning Policy\n\nWe release type changes in minor releases. While stripe-python follows semantic\nversioning, our semantic versions describe the _runtime behavior_ of the\nlibrary alone. Our _type annotations are not reflected in the semantic\nversion_. That is, upgrading to a new minor version of stripe-python might\nresult in your type checker producing a type error that it didn't before. You\ncan use a `~=x.x` or `x.x.*` [version specifier](https://peps.python.org/pep-0440/#examples)\nin your `requirements.txt` to constrain `pip` to a certain minor range of `stripe-python`.\n\n### Types and API Versions\n\nThe types describe the [Stripe API version](https://stripe.com/docs/api/versioning)\nthat was the latest at the time of release. This is the version that your library\nsends by default. If you are overriding `stripe.api_version` / `stripe_version` on the `StripeClient`, or using a\n[webhook endpoint](https://stripe.com/docs/webhooks#api-versions) tied to an older version,\nbe aware that the data you see at runtime may not match the types.\n\n### Public Preview SDKs\n\nStripe has features in the [public preview phase](https://docs.stripe.com/release-phases) that can be accessed via versions of this package that have the `bX` suffix like `12.2.0b2`.\nWe would love for you to try these as we incrementally release new features and improve them based on your feedback.\n\nTo install, pick the latest version with the `bX` suffix by reviewing the [releases page](https://github.com/stripe/stripe-python/releases/) and then use it in the `pip install` command:\n\n```\npip install stripe==<replace-with-the-version-of-your-choice>\n```\n\n> **Note**\n> There can be breaking changes between two versions of the public preview SDKs without a bump in the major version. Therefore we recommend pinning the package version to a specific version in your [pyproject.toml](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#dependencies-and-requirements) or [requirements file](https://pip.pypa.io/en/stable/user_guide/#requirements-files). This way you can install the same version each time without breaking changes unless you are intentionally looking for the latest public preview SDK.\n\nSome preview features require a name and version to be set in the `Stripe-Version` header like `feature_beta=v3`. If your preview feature has this requirement, use the `stripe.add_beta_version` function (available only in the public preview SDKs):\n\n```python\nstripe.add_beta_version(\"feature_beta\", \"v3\")\n```\n\n### Private Preview SDKs\n\nStripe has features in the [private preview phase](https://docs.stripe.com/release-phases) that can be accessed via versions of this package that have the `aX` suffix like `12.2.0a2`. These are invite-only features. Once invited, you can install the private preview SDKs by following the same instructions as for the [public preview SDKs](https://github.com/stripe/stripe-python?tab=readme-ov-file#public-preview-sdks) above and replacing the suffix `b` with `a` in package versions.\n\n### Custom requests\n\nIf you would like to send a request to an undocumented API (for example you are in a private beta), or if you prefer to bypass the method definitions in the library and specify your request details directly, you can use the `raw_request` method on `StripeClient`.\n\n```python\nclient = StripeClient(\"sk_test_...\")\nresponse = client.raw_request(\n \"post\", \"/v1/beta_endpoint\", param=123, stripe_version=\"2022-11-15; feature_beta=v3\"\n)\n\n# (Optional) response is a StripeResponse. You can use `client.deserialize` to get a StripeObject.\ndeserialized_resp = client.deserialize(response, api_mode='V1')\n```\n\n### Async\n\nAsynchronous versions of request-making methods are available by suffixing the method name\nwith `_async`.\n\n```python\n# With StripeClient\nclient = StripeClient(\"sk_test_...\")\ncustomer = await client.v1.customers.retrieve_async(\"cus_xyz\")\n\n# With global client\nstripe.api_key = \"sk_test_...\"\ncustomer = await stripe.Customer.retrieve_async(\"cus_xyz\")\n\n# .auto_paging_iter() implements both AsyncIterable and Iterable\nasync for c in await stripe.Customer.list_async().auto_paging_iter():\n ...\n```\n\nThere is no `.save_async` as `.save` is [deprecated since stripe-python v5](https://github.com/stripe/stripe-python/wiki/Migration-guide-for-v5#deprecated). Please migrate to `.modify_async`.\n\nThe default HTTP client uses `requests` for making synchronous requests but\n`httpx` for making async requests. If you're migrating to async, we recommend\nyou to explicitly initialize your own http client and pass it to StripeClient\nor set it as the global default.\n\nIf you don't already have a dependency on an async-compatible HTTP library, `pip install stripe[async]` will install one for you (new in `v13.0.1`).\n\n```python\n# By default, an explicitly initialized HTTPXClient will raise an exception if you\n# attempt to call a sync method. If you intend to only use async, this is useful to\n# make sure you don't unintentionally make a synchronous request.\nmy_http_client = stripe.HTTPXClient()\n\n# If you want to use httpx to make sync requests, you can disable this\n# behavior.\nmy_http_client = stripe.HTTPXClient(allow_sync_methods=True)\n\n# aiohttp is also available (does not support sync requests)\nmy_http_client = stripe.AIOHTTPClient()\n\n# With StripeClient\nclient = StripeClient(\"sk_test_...\", http_client=my_http_client)\n\n# With the global client\nstripe.default_http_client = my_http_client\n```\n\nYou can also subclass `stripe.HTTPClient` and provide your own instance.\n\n## Support\n\nNew features and bug fixes are released on the latest major version of the Stripe Python library. If you are on an older major version, we recommend that you upgrade to the latest in order to use the new features and bug fixes including those for security vulnerabilities. Older major versions of the package will continue to be available for use, but will not be receiving any updates.\n\n## Development\n\n[Contribution guidelines for this project](CONTRIBUTING.md)\n\nThe test suite depends on [stripe-mock], so make sure to fetch and run it from a\nbackground terminal ([stripe-mock's README][stripe-mock] also contains\ninstructions for installing via Homebrew and other methods):\n\n```sh\ngo install github.com/stripe/stripe-mock@latest\nstripe-mock\n```\n\nWe use [just](https://github.com/casey/just) for conveniently running development tasks. You can use them directly, or copy the commands out of the `justfile`. To our help docs, run `just`. By default, all commands will use an virtualenv created by your default python version (whatever comes out of `python --version`). We recommend using [mise](https://mise.jdx.dev/lang/python.html) or [pyenv](https://github.com/pyenv/pyenv) to control that version.\n\nRun the following command to set up the development virtualenv:\n\n```sh\njust venv\n# or: python -m venv venv && venv/bin/python -I -m pip install -e .\n```\n\nRun all tests:\n\n```sh\njust test\n# or: venv/bin/pytest\n```\n\nRun all tests in a single file:\n\n```sh\njust test tests/api_resources/abstract/test_updateable_api_resource.py\n# or: venv/bin/pytest tests/api_resources/abstract/test_updateable_api_resource.py\n```\n\nRun a single test suite:\n\n```sh\njust test tests/api_resources/abstract/test_updateable_api_resource.py::TestUpdateableAPIResource\n# or: venv/bin/pytest tests/api_resources/abstract/test_updateable_api_resource.py::TestUpdateableAPIResource\n```\n\nRun a single test:\n\n```sh\njust test tests/api_resources/abstract/test_updateable_api_resource.py::TestUpdateableAPIResource::test_save\n# or: venv/bin/pytest tests/api_resources/abstract/test_updateable_api_resource.py::TestUpdateableAPIResource::test_save\n```\n\nRun the linter with:\n\n```sh\njust lint\n# or: venv/bin/python -m flake8 --show-source stripe tests\n```\n\nThe library uses [Ruff][ruff] for code formatting. Code must be formatted\nwith Black before PRs are submitted, otherwise CI will fail. Run the formatter\nwith:\n\n```sh\njust format\n# or: venv/bin/ruff format . --quiet\n```\n\n[api-keys]: https://dashboard.stripe.com/account/apikeys\n[ruff]: https://github.com/astral-sh/ruff\n[connect]: https://stripe.com/connect\n[poetry]: https://github.com/sdispater/poetry\n[stripe-mock]: https://github.com/stripe/stripe-mock\n[idempotency-keys]: https://stripe.com/docs/api/idempotent_requests?lang=python\n\n<!--\n# vim: set tw=79:\n-->\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Python bindings for the Stripe API",
"version": "13.0.1",
"project_urls": {
"changelog": "https://github.com/stripe/stripe-python/blob/master/CHANGELOG.md",
"documentation": "https://stripe.com/docs/api/?lang=python",
"homepage": "https://stripe.com/",
"issues": "https://github.com/stripe/stripe-python/issues",
"source": "https://github.com/stripe/stripe-python"
},
"split_keywords": [
"stripe",
" api",
" payments"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "3aaca911f3c850420ab42447f5c049f570e55f34e0aa0b2e6a1d1a059a5656c4",
"md5": "617ed3f1c206ecfebf00c445e693cc6d",
"sha256": "7804cee14580ab37bbc1e5f6562e49dea0686ab3cb34384eb9386387ed8ebd0c"
},
"downloads": -1,
"filename": "stripe-13.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "617ed3f1c206ecfebf00c445e693cc6d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 1849008,
"upload_time": "2025-10-03T19:37:14",
"upload_time_iso_8601": "2025-10-03T19:37:14.953484Z",
"url": "https://files.pythonhosted.org/packages/3a/ac/a911f3c850420ab42447f5c049f570e55f34e0aa0b2e6a1d1a059a5656c4/stripe-13.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "d836edac714e44a1a0048e74cc659b6070b42dd7027473e8f9f06a727b3860b6",
"md5": "03337af3f15ab123c8b2b47222973146",
"sha256": "5869739430ff73bd9cd81275abfb79fd4089e97e9fd98d306a015f5defd39a0d"
},
"downloads": -1,
"filename": "stripe-13.0.1.tar.gz",
"has_sig": false,
"md5_digest": "03337af3f15ab123c8b2b47222973146",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 1263853,
"upload_time": "2025-10-03T19:37:17",
"upload_time_iso_8601": "2025-10-03T19:37:17.335302Z",
"url": "https://files.pythonhosted.org/packages/d8/36/edac714e44a1a0048e74cc659b6070b42dd7027473e8f9f06a727b3860b6/stripe-13.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-03 19:37:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "stripe",
"github_project": "stripe-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "stripe"
}