Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
NotificationsYou must be signed in to change notification settings

Basis-Theory/python-sdk

Repository files navigation

fern shieldpypi

The BasisTheory Python library provides convenient access to the BasisTheory API from Python.

Documentation

API reference documentation is availablehere.

Installation

pip install BasisTheoryClient

Usage

Instantiate and use the client with the following:

frombasis_theoryimportBasisTheoryclient=BasisTheory(api_key="YOUR_API_KEY",)client.tenants.self_.get()

Async Client

The SDK also exports anasync client so that you can make non-blocking calls to our API.

importasynciofrombasis_theoryimportAsyncBasisTheoryclient=AsyncBasisTheory(api_key="YOUR_API_KEY",)asyncdefmain()->None:awaitclient.tenants.self_.get()asyncio.run(main())

Exception Handling

When the API returns a non-success status code (4xx or 5xx response), a subclass of the following errorwill be thrown.

frombasis_theory.core.api_errorimportApiErrortry:client.tenants.self_.get(...)exceptApiErrorase:print(e.status_code)print(e.body)

Pagination

Paginated requests will return aSyncPager orAsyncPager, which can be used as generators for the underlying object.

frombasis_theoryimportBasisTheoryclient=BasisTheory(api_key="YOUR_API_KEY",)response=client.applications.list()foriteminresponse:yielditem# alternatively, you can paginate page-by-pageforpageinresponse.iter_pages():yieldpage

Advanced

Retries

The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as longas the request is deemed retriable and the number of retry attempts has not grown larger than the configuredretry limit (default: 2).

A request is deemed retriable when any of the following HTTP status codes is returned:

  • 408 (Timeout)
  • 429 (Too Many Requests)
  • 5XX (Internal Server Errors)

Use themax_retries request option to configure this behavior.

client.tenants.self_.get(..., {"max_retries":1})

Timeouts

The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.

frombasis_theoryimportBasisTheoryclient=BasisTheory(    ...,timeout=20.0,)# Override timeout for a specific methodclient.tenants.self_.get(..., {"timeout_in_seconds":1})

Custom Client

You can override thehttpx client to customize it for your use-case. Some common use-cases include support for proxiesand transports.

importhttpxfrombasis_theoryimportBasisTheoryclient=BasisTheory(    ...,httpx_client=httpx.Client(proxies="http://my.test.proxy.example.com",transport=httpx.HTTPTransport(local_address="0.0.0.0"),    ),)

Contributing

While we value open-source contributions to this SDK, this library is generated programmatically.Additions made directly to this library would have to be moved over to our generation code,otherwise they would be overwritten upon the next generated release. Feel free to open a PR asa proof of concept, but know that we will not be able to merge it as-is. We suggest openingan issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp