SDK — DEVELOPERS

Privacy SDK — Python, Node.js, cURL Examples

Analyze, anonymize, encrypt, decrypt PII via REST API. Token-based pricing (200 free tokens). Bearer token auth. Sub-200ms response time. Code examples for Python, Node.js, JavaScript, cURL.

SDK & Code Examples

🐍 Python SDK

pip install anonym-legal
# Coming soon

import anonymize

client = anonymize.Client(
    api_key="YOUR_API_KEY",
    base_url="https://anonym.legal/api"
)

result = client.analyze(
    text="John Smith, SSN 123-45-6789",
    language="en"
)
print(result.entities)

📦 Node.js SDK

npm install @anonym-legal/sdk
# Coming soon

const { AnonymClient } = require(
  "@anonym-legal/sdk"
);

const client = new AnonymClient({
  apiKey: process.env.API_KEY
});

const result = await client.analyze({
  text: "Jane Doe, email jane@ex.com",
  language: "en"
});
console.log(result.entities);

Yes. Install with pip install anonym-legal. The Python SDK wraps the REST API with type hints, async support, and automatic retry. 3 lines to anonymize: client = AnonymLegal(token); result = client.anonymize(text, language='en').

The MCP Server exposes 7 privacy tools that LangChain agents can call directly. Add pii_detect, pii_anonymize, pii_decrypt to your agent toolkit. Prevents PII leakage in RAG pipelines and agent workflows.

Sub-200ms for standard text requests. Batch endpoints process arrays of text in a single call. The API runs on EU servers with zero data retention — request data is processed and immediately discarded.

The API runs on our EU-hosted infrastructure with zero data retention. For enterprise self-hosting requirements, contact us. The MCP Server can also run locally with Docker.

Yes. Send arrays of text strings in a single API call. The batch endpoint processes up to 100 items per request with consistent sub-200ms per-item latency.

Free tier: 200 tokens/month with all features. Basic: €3/month (1,000 tokens). Pro: €15/month (4,000 tokens). Business: €29/month (10,000 tokens). One token = one API call.

API Endpoints

📋 /analyze

Detect & extract PII entities from text. Returns entity types, positions, confidence scores.

🔒 /anonymize

Replace detected PII with redactions, masks, hashes, or encryption. Returns anonymized text.

🔓 /decrypt

Decrypt previously encrypted PII. Requires decryption key. Bearer token auth.

cURL Example: Analyze

curl -X POST https://anonym.legal/api/presidio/analyze \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "John Smith works at Acme Corp",
    "language": "en"
  }'

# Response
{
  "entities": [
    {
      "type": "PERSON",
      "value": "John Smith",
      "start": 0,
      "end": 10,
      "score": 0.95
    },
    {
      "type": "ORGANIZATION",
      "value": "Acme Corp",
      "start": 21,
      "end": 30,
      "score": 0.88
    }
  ]
}

Token-Based Pricing

Free Plan

200 tokens/month. 1 token per 100 characters analyzed. Ideal for learning & testing.

Pro Plan

€3/1,000 tokens. Scale to 100K+ characters/month. Priority support.

Use Case: AI Pipeline Integration

LLM Privacy Layer

from langchain.chat_models import ChatOpenAI
from anonym_legal import AnonymClient

client = AnonymClient(api_key=KEY)
llm = ChatOpenAI(model="gpt-4")

# Customer input with PII
user_input = "My name is John, SSN 123-45-6789"

# Sanitize before LLM
sanitized = client.anonymize(
    text=user_input,
    method="mask"
)

# Safe to send to LLM
response = llm.predict(text=sanitized)

Watch the API In Action

See PII detection and anonymization via REST API and MCP Server

Get Started with API

Sign up for free API key. 200 tokens included. Code examples in Python, Node.js, cURL. Sub-200ms response time.

Get API Key

Frequently Asked Questions

Install via pip: pip install anonym-legal. Import and initialize: from anonym import Client; client = Client(api_key='your-token'). Call client.anonymize(text='John Smith, SSN 123-45-6789') to get anonymized output.

Currently Python and Node.js SDKs are available, plus cURL for any language. The REST API works with any HTTP client — Go (net/http), Java (OkHttp/HttpClient), Ruby (Net::HTTP), PHP (Guzzle), C# (HttpClient), Rust (reqwest).

Bearer token authentication. Generate your API token at anonym.legal/app/admin. Pass it as Authorization: Bearer YOUR_TOKEN header. The SDK handles authentication automatically when initialized with your token.