Skip to main content

BasisTheory Python SDK

Project description

Basis Theory Python SDK

Verify

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)

Project details


Download files

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

Source Distribution

basistheory-1.6.1.tar.gz (84.6 kB view details)

Uploaded Source

Built Distributions

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

basistheory-1.6.1-py3.8.egg (568.0 kB view details)

Uploaded Egg

basistheory-1.6.1-py3-none-any.whl (252.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: basistheory-1.6.1.tar.gz
  • Upload date:
  • Size: 84.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.14

File hashes

Hashes for basistheory-1.6.1.tar.gz
Algorithm Hash digest
SHA256 a625e8b3742c5f6cbf04f68e2fc1efa0a4609136e902bd5a45e05f3ca190ee0b
MD5 90dd7eb92f3599cbe02f901d52a4cf67
BLAKE2b-256 dced69ed7fa84319fc77acef7f10047f0fc948cc06fe404ee4a7f68969ade66f

See more details on using hashes here.

File details

Details for the file basistheory-1.6.1-py3.8.egg.

File metadata

  • Download URL: basistheory-1.6.1-py3.8.egg
  • Upload date:
  • Size: 568.0 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.14

File hashes

Hashes for basistheory-1.6.1-py3.8.egg
Algorithm Hash digest
SHA256 4071749575ec288e3e28a296df7f41856ece65f609dc18e84b1d42ba0a2bb57b
MD5 1f9a67b29c09426ace78fc8216f05af1
BLAKE2b-256 746d1893653d9b1ba833aa6e2ade20c12409061ea1033b16a0a34dbcb25102b8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: basistheory-1.6.1-py3-none-any.whl
  • Upload date:
  • Size: 252.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.14

File hashes

Hashes for basistheory-1.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8dc40fe050628a72f303193cd2c0cf9df39bba2174c4cf2c050e5fa9c2b063b3
MD5 f7d06a7c025f83a3caf947685aa106e1
BLAKE2b-256 364e3765a8cbb8c42051be379601765e78639f9b5e528d9f9b68c7a75119524f

See more details on using hashes here.

Supported by

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