A client library for accessing Sensitive Data Protection API
Project description
quba-sensitive-data-protection
A client library for accessing Sensitive Data Protection API — a Python client for detecting and de-identifying sensitive data (PII) in text: scan for entities (emails, names, phone numbers, …) and anonymize them with configurable rules (redact, mask, replace, hash, encrypt).
Installation
pip install quba-sensitive-data-protection
# or
uv add quba-sensitive-data-protection
Quickstart
from quba_sdp import Client, models
from quba_sdp.api import scan_text, anonymize_text
client = Client() # defaults to the production API; pass base_url=... to override
# --- scan: locate sensitive entities ---
resp = scan_text.sync(client=client, body=models.ScanRequestBody(text="Email me at a@b.com"))
if isinstance(resp, models.ScanResponseBody):
for r in resp.results:
print(r.entity_type, r.start, r.end, r.score)
# --- anonymize: transform matches ---
body = models.AnonymizeRequestBody(
text="Email me at a@b.com",
rules=[
models.MaskRule(entities=[models.ModelEntity(value="email")], masking_char="*"),
],
)
result = anonymize_text.sync(client=client, body=body)
if isinstance(result, models.AnonymizeResponseBody):
print(result.text) # 'Email me at ***********'
Base URL
Client() targets the production API by default. Override it for local or
staging:
client = Client(base_url="http://localhost:8000")
Authentication
The production API requires a token — use AuthenticatedClient (it shares the
same default base URL):
from quba_sdp import AuthenticatedClient
client = AuthenticatedClient(token="SuperSecretToken")
Calling endpoints
Every operation lives in a module under quba_sdp.api and exposes four
functions:
| function | blocking | returns |
|---|---|---|
sync |
✅ | parsed body, or None for an undocumented/error status |
sync_detailed |
✅ | Response[...] with .status_code, .headers, .parsed |
asyncio |
— | like sync, awaitable |
asyncio_detailed |
— | like sync_detailed, awaitable |
sync returns a union of the success body and any documented error (e.g.
HTTPValidationError), so narrow it before use:
r = scan_text.sync(client=client, body=...)
if isinstance(r, models.ScanResponseBody):
... # success
else:
... # HTTPValidationError or None
Async variant:
async with Client() as client:
resp = await scan_text.asyncio(client=client, body=models.ScanRequestBody(text="..."))
Advanced configuration
Client / AuthenticatedClient accept timeout=, verify_ssl=, headers=,
cookies=, and httpx_args= for full control of the underlying httpx client
(see the Client docstring). Disabling TLS verification is a security risk:
client = Client(verify_ssl=False) # not recommended
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 quba_sensitive_data_protection-0.0.8.tar.gz.
File metadata
- Download URL: quba_sensitive_data_protection-0.0.8.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aad1d6996386e6f971bd15c17729f42458b0250753992b3940a2433088ebeb32
|
|
| MD5 |
71f7366bab4534e336b401a3f2bca259
|
|
| BLAKE2b-256 |
9ebb24564928f8a93be54566ff177f368ad3170a5357b84f02e989aa160d5fed
|
File details
Details for the file quba_sensitive_data_protection-0.0.8-py3-none-any.whl.
File metadata
- Download URL: quba_sensitive_data_protection-0.0.8-py3-none-any.whl
- Upload date:
- Size: 32.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
023d9f1c2b7180684e5111ac43a2545adf238b5a51c64258adefb2fc69602ae4
|
|
| MD5 |
77043ac50e58d53e445ad2e63c00e6da
|
|
| BLAKE2b-256 |
6439fa866635ea483a78d5d5dda40e45d9790fc114dc44ba84f85e22b63af877
|