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 expunct

Quick Example

Synchronous

from expunct import Expunct client = Expunct(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 expunct import AsyncExpunct async def main(): client = AsyncExpunct(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.expunct.aiAPI base URL
timeoutfloat30.0Request timeout in seconds
max_retriesint3Maximum retry attempts for transient failures
client = Expunct( api_key="pk_live_...", base_url="https://api.expunct.ai", 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