Skip to content

Basis-Theory/basistheory-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 [email protected] 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)

Documentation for API Endpoints

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

Class Method HTTP request Description
ApplicationKeysApi create POST /applications/{id}/keys
ApplicationKeysApi delete DELETE /applications/{id}/keys/{keyId}
ApplicationKeysApi get GET /applications/{id}/keys
ApplicationKeysApi get_by_id GET /applications/{id}/keys/{keyId}
ApplicationTemplatesApi get GET /application-templates
ApplicationTemplatesApi get_by_id GET /application-templates/{id}
ApplicationsApi create POST /applications
ApplicationsApi delete DELETE /applications/{id}
ApplicationsApi get GET /applications
ApplicationsApi get_by_id GET /applications/{id}
ApplicationsApi get_by_key GET /applications/key
ApplicationsApi regenerate_key POST /applications/{id}/regenerate
ApplicationsApi update PUT /applications/{id}
DetokenizeApi detokenize POST /detokenize
EnrichmentsApi bank_account_verify POST /enrichments/bank-account-verify
LogsApi get GET /logs
LogsApi get_entity_types GET /logs/entity-types
PermissionsApi get GET /permissions
ProxiesApi create POST /proxies
ProxiesApi delete DELETE /proxies/{id}
ProxiesApi get GET /proxies
ProxiesApi get_by_id GET /proxies/{id}
ProxiesApi patch PATCH /proxies/{id}
ProxiesApi update PUT /proxies/{id}
ReactorFormulasApi create POST /reactor-formulas
ReactorFormulasApi delete DELETE /reactor-formulas/{id}
ReactorFormulasApi get GET /reactor-formulas
ReactorFormulasApi get_by_id GET /reactor-formulas/{id}
ReactorFormulasApi update PUT /reactor-formulas/{id}
ReactorsApi create POST /reactors
ReactorsApi delete DELETE /reactors/{id}
ReactorsApi get GET /reactors
ReactorsApi get_by_id GET /reactors/{id}
ReactorsApi patch PATCH /reactors/{id}
ReactorsApi react POST /reactors/{id}/react
ReactorsApi react_async POST /reactors/{id}/react-async
ReactorsApi result_get_by_id GET /reactors/{id}/results/{requestId}
ReactorsApi update PUT /reactors/{id}
RolesApi get GET /roles
SessionsApi authorize POST /sessions/authorize
SessionsApi create POST /sessions
TenantsApi create_connection POST /tenants/self/connections
TenantsApi create_invitation POST /tenants/self/invitations
TenantsApi delete DELETE /tenants/self
TenantsApi delete_connection DELETE /tenants/self/connections
TenantsApi delete_invitation DELETE /tenants/self/invitations/{invitationId}
TenantsApi delete_member DELETE /tenants/self/members/{memberId}
TenantsApi get GET /tenants/self
TenantsApi get_invitations GET /tenants/self/invitations
TenantsApi get_members GET /tenants/self/members
TenantsApi get_tenant_usage_report GET /tenants/self/reports/usage
TenantsApi owner_get GET /tenants/self/owner
TenantsApi resend_invitation POST /tenants/self/invitations/{invitationId}/resend
TenantsApi update PUT /tenants/self
TenantsApi update_member PUT /tenants/self/members/{memberId}
ThreeDSApi three_ds_authenticate_session POST /3ds/sessions/{sessionId}/authenticate
ThreeDSApi three_ds_create_session POST /3ds/sessions
ThreeDSApi three_ds_get_challenge_result GET /3ds/sessions/{sessionId}/challenge-result
ThreeDSApi three_ds_get_session_by_id GET /3ds/sessions/{id}
TokenizeApi tokenize POST /tokenize
TokensApi create POST /tokens
TokensApi delete DELETE /tokens/{id}
TokensApi get GET /tokens
TokensApi get_by_id GET /tokens/{id}
TokensApi get_v2 GET /v2/tokens
TokensApi search POST /tokens/search
TokensApi search_v2 POST /v2/tokens/search
TokensApi update PATCH /tokens/{id}

Documentation For Models