Skip to main content

Basis Theory Python SDK

Release

The Basis Theory Python SDK for Python >=3.7

Installation

pip install

From the git repository

pip install git+https://github.com/Basis-Theory/basistheory-python.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/Basis-Theory/basistheory-python.git)

Then import the package:

import basistheory

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import basistheory

Locally

To install your latest changes locally run:

python3 -m pip install .

Documentation

If you need any assistance, please contact support@basistheory.com at this time.

Client Methods

All URIs are relative to https://api.basistheory.com

Class Method HTTP request
TokensApi create POST /tokens
TokensApi delete DELETE /tokens/{id}
TokensApi get_by_id GET /tokens/{id}
TokensApi list GET /tokens

Models

Usage

Per-request configuration

All of the client methods accept an optional RequestOptions object.
This is used if you want to set a correlation ID or if you want to set a per-request BT-API-KEY

import uuid
import basistheory
from basistheory.request_options import RequestOptions

request_options = RequestOptions(api_key="API KEY", correlation_id=uuid.uuid4())

Client Configuration

Each Api client can be configured to use a custom API url and client-wide BT-API-KEY.

import basistheory
from basistheory.api import tokens_api

configuration = basistheory.Configuration(
    host = "https://token-proxy.somedomain.com",
    api_key = "API KEY"
)

with basistheory.ApiClient(configuration) as api_client:
    # Create a token client w/ global configuration for all requests
    token_client = tokens_api.TokensApi(api_client)

Getting Started

Quick example creating a token and then retrieving it.

import uuid
import basistheory
from pprint import pprint
from basistheory.api import tokens_api
from basistheory.model.create_token_request import CreateTokenRequest
from basistheory.request_options import RequestOptions

# Defining client wide api_key
configuration = basistheory.Configuration(
    api_key = "API KEY"
)

with basistheory.ApiClient(configuration) as api_client:
    # Create an instance of the tokens API client
    token_client = tokens_api.TokensApi(api_client)

    # Setting a correlation Id
    request_options = RequestOptions(correlation_id=uuid.uuid4().__str__())

    # Token request object
    request = CreateTokenRequest(type="token", data="My Secret Data")

    try:
        # Creating the token
        created_token = token_client.create(create_token_request=request, request_options=request_options)
        pprint(created_token)

        # Retrieving it (requires read permission on the token type classification and impact level)
        retrieved_token = token_client.get_by_id(id=created_token.id)
        pprint(retrieved_token)
    except basistheory.ApiException as e:
        print("Exception when calling TokensApi: %s\n" % e)

Download files

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

Source Distribution

basistheory-3.0.0.tar.gz (108.6 kB view details)

Uploaded Source

Built Distribution

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

basistheory-3.0.0-py3-none-any.whl (390.1 kB view details)

Uploaded Python 3

File details

Details for the file basistheory-3.0.0.tar.gz.

File metadata

  • Download URL: basistheory-3.0.0.tar.gz
  • Upload date:
  • Size: 108.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.18

File hashes

Hashes for basistheory-3.0.0.tar.gz
Algorithm Hash digest
SHA256 4c55e8f5a63c07ec22ec3ac43a83dae729341c2dcdf8eae4e65fa9c9c0165466
MD5 ee68e68ab7a548c959c4c68635232543
BLAKE2b-256 f6674ca9eff8f0acf9ebf42a61f26947229f5eca2c33734d4ff2257291bf7d14

See more details on using hashes here.

File details

Details for the file basistheory-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: basistheory-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 390.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.18

File hashes

Hashes for basistheory-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 702119c56d4067d2eedb38c2a4aade73eb272147a724491c80114afecb27ca9c
MD5 0afcab4b610d5ed3f0e7fa9582e54379
BLAKE2b-256 98edc5c56fc0b8c19128eb294fa461f0908e5005e41af790b466e038ac9e85c4

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

3.0.0 This release

2 files

2.2.0

2 files

2.1.0

2 files

2.0.0

2 files

1.11.3

2 files

1.11.2

2 files

1.11.1

2 files

1.11.0

2 files

1.10.2

2 files

1.10.1

2 files

1.10.0

2 files

1.9.0

2 files

1.8.0

3 files

1.7.0

3 files

1.6.1

3 files

1.6.0

3 files

1.5.0

3 files

1.4.1

3 files

1.4.0

3 files

1.3.0

3 files

1.2.0

3 files

1.0.0

2 files

0.14.0

2 files

0.13.0

2 files

0.12.0

2 files

0.11.0

2 files

0.10.1

2 files

0.10.0

2 files

0.9.1

2 files

0.9.0

2 files

0.8.1

2 files

0.8.0

2 files

0.7.0

2 files

0.6.1

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.1

2 files

Supported by

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