Skip to main content

Python client for the Subzero tokenization vault

Project description

Subzero Python SDK

Thin Python client for the Subzero tokenization vault.

Configure entity types, API keys, and reveal policies in the dashboard first. This SDK is for server-side vault operations only.

Install

cd python-sdk
pip install -e ".[dev]"

Quick start

from subzero import SubzeroClient

client = SubzeroClient(
    tokenize_key="sz_live_...",   # tokenize + search + batch
    reveal_key="sz_live_...",     # reveal
    base_url="https://api.yourcompany.com",
)
client.ready()

token = client.tokenize("SSN", "123-45-6789")
found = client.search("SSN", "123-45-6789")   # blind index lookup
value = client.reveal(token)

Or from environment variables:

client = SubzeroClient.from_env()  # SUBZERO_API_KEY or split keys; SUBZERO_BASE_URL

A single api_key works when one key has both scopes (e.g. admin):

client = SubzeroClient(api_key="sz_live_...")

API key scopes

Scope SDK methods
tokenize tokenize, search, tokenize_batch
reveal reveal (requires a matching reveal policy in the dashboard)
admin All of the above (bypasses reveal policy)

Use separate tokenize_key and reveal_key in production for least privilege.

Batch tokenize

For ETL pipelines. Max 100 items per API request; the SDK auto-chunks larger lists.

from subzero import TokenizeBatchItem, TokenizeBatchContext

results = client.tokenize_batch(
    [
        TokenizeBatchItem(index=0, entity_type="SSN", value="123-45-6789"),
        TokenizeBatchItem(index=1, entity_type="SSN", value="987-65-4321"),
    ],
    context=TokenizeBatchContext(source="dbt", pipeline_id="contacts"),
)

for item in results:
    if item.ok:
        print(item.index, item.token)
    else:
        print(item.index, item.error)  # per-item errors do not fail the batch

Example

With the API running and keys configured in the dashboard:

export SUBZERO_TOKENIZE_API_KEY=sz_live_...
export SUBZERO_REVEAL_API_KEY=sz_live_...
export SUBZERO_BASE_URL=http://127.0.0.1:8000

python examples/vault_demo.py

Tests

pytest

PyPI

Local editable install only for now.

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

iceberg_subzero-0.2.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

iceberg_subzero-0.2.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file iceberg_subzero-0.2.0.tar.gz.

File metadata

  • Download URL: iceberg_subzero-0.2.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.8

File hashes

Hashes for iceberg_subzero-0.2.0.tar.gz
Algorithm Hash digest
SHA256 13614b29e346689462ec638cd5c3d6790f272f8aba2a2e25ebf695dd0cf9230e
MD5 6871bd8b51a42df173e7c760223cd823
BLAKE2b-256 50305ff3b9ea1461e82e9dae78771673905ff42357db840b7cd850bb8d4293fb

See more details on using hashes here.

File details

Details for the file iceberg_subzero-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for iceberg_subzero-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6929db722c0ae9bce5b861ef4b8061201d0cbc747d91451d880f527c6180d440
MD5 e84facd9c1437e4e7b600e872b52629e
BLAKE2b-256 0f190ec986067ef57fcc949e97910d14250fd708a69555100fc1ae3f031d939d

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