Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

basistheory

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

basistheory

BasisTheory Python SDK

  • 3.0.0
  • PyPI
  • Socket score

Maintainers
1

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

ClassMethodHTTP request
TokensApicreatePOST /tokens
TokensApideleteDELETE /tokens/{id}
TokensApiget_by_idGET /tokens/{id}
TokensApilistGET /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)

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc