Redact PII with Python
There is no SDK to install: the API is a single POST endpoint that returns JSON. The snippet below wraps it in a function you can drop into an ingestion job.
Code
import requests
def redact(text: str, style: str = "replace") -> dict:
r = requests.post(
"https://api.bitbanger.in/v1/redact",
headers={"X-API-Key": "rdct_your_key_here"},
json={"text": text, "style": style},
timeout=30,
)
r.raise_for_status()
return r.json()
result = redact("Invoice for Jane Doe, jane.doe@example.com, card 4242 4242 4242 4242")
print(result["redacted"])
for hit in result["entities"]:
print(hit["entity"], hit["start"], hit["end"])
Notes
- Use httpx if your codebase already depends on it; the request shape is identical.
- Set a timeout. Inference is fast but the first request after a deploy waits for the model to load.
- The response is JSON, so no parsing layer is needed beyond r.json().