Official Veilio SDK for Python - Data tokenization and cyber-resilience API client
Project description
veilio-sdk
Official Python SDK for Veilio - Data tokenization and cyber-resilience API.
Installation
pip install veilio-sdk
Quick Start
from veilio_sdk import VeilioClient
# Initialize client
client = VeilioClient(
api_key="veil_dev_your-api-key-here",
base_url="https://app.veilio.xyz/api" # Optional, defaults to production
)
# Tokenize sensitive data
result = client.tokenize(
data="john@example.com",
type="email"
)
print(f"Token: {result['token']}")
# Detokenize when needed
original = client.detokenize(
token=result["token"],
reason="Send email notification"
)
print(f"Original: {original['data']}")
Features
- ✅ Simple tokenization - Tokenize single fields
- ✅ Bulk operations - Tokenize/detokenize multiple fields at once
- ✅ Multi-format support - JSON, CSV, SQL formats
- ✅ Crypto shredding - Immediate token shredding (
shred_token) - ✅ Retention policies - Automatic shredding via
retention - ✅ Automatic retries - Handles rate limits and network errors
- ✅ Error handling - Clear error messages and types
- ✅ Type hints - Full type annotations included
API Reference
Constructor
client = VeilioClient(
api_key: str, # Required: Your Veilio API key
base_url: str = "https://app.veilio.xyz/api", # Optional
timeout: int = 30, # Optional: Request timeout in seconds
max_retries: int = 3 # Optional: Max retries for failed requests
)
Methods
tokenize(data, type=None, metadata=None, retention=None)
Tokenize a single field.
result = client.tokenize(
data="john@example.com",
type="email", # Optional
metadata={"source": "form"}, # Optional
retention={ # Optional
"ttlDays": 30
# or "retentionUntil": "2026-12-31T23:59:59.000Z"
}
)
# Returns: {"token": str, "createdAt": str, "retentionUntil": str | None}
tokenize_bulk(fields)
Tokenize multiple fields in one request.
result = client.tokenize_bulk([
{"data": "john@example.com", "type": "email"},
{"data": "+33612345678", "type": "phone"}
])
# Returns: {
# "tokens": [...],
# "summary": {"total": int, "success": int, "failed": int},
# "errors": [...], # Optional
# "createdAt": str
# }
detokenize(token, reason=None)
Detokenize a single token.
result = client.detokenize(
token="tok_abc123...",
reason="Send email" # Optional
)
# Returns: {"data": str, "accessedAt": str}
shred_token(token, reason=None)
Shred a token immediately (cryptographic erasure).
result = client.shred_token(
token="tok_abc123...",
reason="GDPR delete request" # Optional
)
# Returns: {"token": str, "shreddedAt": str}
detokenize_bulk(tokens)
Detokenize multiple tokens in one request.
result = client.detokenize_bulk([
{"token": "tok_abc123...", "reason": "Processing"},
{"token": "tok_def456...", "reason": "Processing"}
])
# Returns: {
# "results": [...],
# "summary": {"total": int, "success": int, "failed": int},
# "errors": [...], # Optional
# "accessedAt": str
# }
tokenize_format(data, format=None, options=None)
Tokenize structured data (JSON, CSV, SQL).
json_data = '{"email": "john@example.com"}'
result = client.tokenize_format(
data=json_data,
format="json", # Optional: auto-detected if omitted
options={
"fields": ["email"] # Optional: tokenize only specific fields
}
)
# Returns: {
# "format": str,
# "tokenizedData": str,
# "tokens": [...],
# "metadata": {...},
# "summary": {"totalFields": int, "tokenizedFields": int}
# }
detokenize_format(tokenized_data, format, tokens)
Detokenize structured data.
result = client.detokenize_format(
tokenized_data='{"email": "tok_abc123..."}',
format="json",
tokens=[{"path": "email", "token": "tok_abc123..."}]
)
# Returns: {
# "format": str,
# "detokenizedData": str,
# "summary": {"tokensProcessed": int}
# }
Examples
Basic Usage
from veilio_sdk import VeilioClient
import os
client = VeilioClient(api_key=os.getenv("VEILIO_API_KEY"))
# Tokenize
token = client.tokenize(data="sensitive@data.com", type="email")
# Store token in your database
# db.execute("INSERT INTO users (email) VALUES (?)", (token["token"],))
# Later, detokenize when needed
user = db.get_user(user_id)
email = client.detokenize(token=user.email, reason="Send notification")
Bulk Operations
# Tokenize multiple fields at once
result = client.tokenize_bulk([
{"data": "john@example.com", "type": "email"},
{"data": "+33612345678", "type": "phone"},
{"data": "123-45-6789", "type": "ssn"}
])
# Check for errors
if result["summary"]["failed"] > 0:
print(f"Errors: {result.get('errors', [])}")
# Use the tokens
for token_result in result["tokens"]:
print(f"Token: {token_result['token']}")
Format Tokenization
# Tokenize JSON data
json_data = json.dumps({
"users": [
{"email": "john@example.com", "phone": "+33612345678"}
]
})
result = client.tokenize_format(data=json_data, format="json")
# Store tokenized JSON
# db.save(result["tokenizedData"])
# Later, detokenize
recovered = client.detokenize_format(
tokenized_data=result["tokenizedData"],
format="json",
tokens=[{"path": t["path"], "token": t["token"]} for t in result["tokens"]]
)
Error Handling
from veilio_sdk import (
VeilioClient,
VeilioError,
AuthenticationError,
RateLimitError,
TokenShreddedError,
)
try:
result = client.tokenize(data="test")
except AuthenticationError as e:
print(f"Auth error: {e.message}")
except RateLimitError as e:
print(f"Rate limit: {e.message}, retry after {e.retry_after}s")
except TokenShreddedError as e:
print(f"Token shredded: {e.message}")
except VeilioError as e:
print(f"API error: {e.code} - {e.message}")
Error Codes
AUTH_ERROR- Invalid or missing API keyVALIDATION_ERROR- Invalid request dataRATE_LIMIT_ERROR- Rate limit exceededPLAN_LIMIT- Plan limit exceededTOKEN_SHREDDED- Token has been cryptographically shreddedINTERNAL_ERROR- Server error
Requirements
- Python 3.8+
requestslibrary
License
MIT
Support
- Documentation: https://docs.veilio.xyz
- Support: support@veilio.xyz
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file veilio_sdk-1.1.1.tar.gz.
File metadata
- Download URL: veilio_sdk-1.1.1.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e402022aca5bdabead2eac70fd4b725a9629a0f488cc680658c85bdd57b8ca73
|
|
| MD5 |
59b4f0351a1bf8032a04e2f62cbbbe15
|
|
| BLAKE2b-256 |
2d5e6f5977b6a167f31471cfe886ace468bddee6c60bbe8455649b17f8863678
|
File details
Details for the file veilio_sdk-1.1.1-py3-none-any.whl.
File metadata
- Download URL: veilio_sdk-1.1.1-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b183a1f2ff468994adb4912641e150bb515206afbfa4204d00a32622ff6e7a1
|
|
| MD5 |
cdccb3a7ccc7b5a6058bfed62ec9dc57
|
|
| BLAKE2b-256 |
c5a38cc0d3026fbeb313a3c846d77120f74e3a85ac7d7299b1c6cf236eea2838
|