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.

See docs/vault-sdk.md for the full integration guide.

Install

pip install iceberg-subzero

Quick start

from subzero import SubzeroClient

client = SubzeroClient(
    tokenize_key="sz_live_...",   # tokenize + search + batch
    reveal_key="sz_live_...",     # reveal
)
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_...
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.1.tar.gz (7.5 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.1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: iceberg_subzero-0.2.1.tar.gz
  • Upload date:
  • Size: 7.5 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.1.tar.gz
Algorithm Hash digest
SHA256 a17948127bffe639e176eced3658f94f417a771f25e9216b69cbd41da8035af5
MD5 55eb3cef5d17bffde352054302d48516
BLAKE2b-256 fa68d3259868d5170d50ec19b6e41f9d743d7b74f59631c57fb55aa0d0db8334

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for iceberg_subzero-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a7bd5a14ac3d9fff9432fcec1fc0ec8321b8537f2c877bf3c8331a1a5c2568c9
MD5 c9b4ac9330217176d9f82a20872bc917
BLAKE2b-256 47c87c6c10334675e3621a956813d01876aa73db3f6c802b012a3ef04c999a9b

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