Skip to Content
SDKsPython SDKGetting Started

Python SDK — Getting Started

The Expunct Python SDK provides a type-safe client for the Expunct API, with both synchronous and asynchronous interfaces.

Requirements

  • Python 3.10 or later
  • Dependencies: httpx, pydantic

Installation

pip install pii-redactor-sdk

Quick Example

Synchronous

from pii_redactor_sdk import PiiRedactor client = PiiRedactor(api_key="pk_live_...") result = client.redact.text( text="John Smith's email is john@example.com", ) print(result.redacted_text) # "[PERSON]'s email is [EMAIL_ADDRESS]"

Asynchronous

import asyncio from pii_redactor_sdk import AsyncPiiRedactor async def main(): client = AsyncPiiRedactor(api_key="pk_live_...") result = await client.redact.text( text="John Smith's email is john@example.com", ) print(result.redacted_text) asyncio.run(main())

Configuration

ParameterTypeDefaultDescription
api_keystrrequiredYour API key (starts with pk_live_ or pk_test_)
base_urlstrhttps://api.pii-redactor.devAPI base URL
timeoutfloat30.0Request timeout in seconds
max_retriesint3Maximum retry attempts for transient failures
client = PiiRedactor( api_key="pk_live_...", base_url="https://api.pii-redactor.dev", timeout=60.0, max_retries=5, )

Convenience Methods

The SDK provides shorthand methods for the most common operations:

# Redact text inline result = client.sanitize_text("Call me at 555-0123") # Redact a file (returns a job) job = client.sanitize_file("s3://my-bucket/document.pdf") # Redact content at a URI (returns a job) job = client.sanitize_uri("https://example.com/page")

Next Steps