Call Privacy APIs Directly
HTTP endpoints. Bearer token auth. Curl, Python, Node.js examples. Sub-200ms latency. No SDKs required. Full REST semantics.
Base Endpoints
Base URL: https://anonym.legal/api/presidio
Auth: Authorization: Bearer YOUR_API_KEY
All endpoints support POST with JSON body. Responses are JSON.
Endpoint Reference
/analyze
Detect PII entities in text
POST /api/presidio/analyze
Authorization: Bearer KEY
Content-Type: application/json
{
"text": "My email is john@example.com and SSN is 123-45-6789",
"language": "en"
}
Response:
{
"results": [
{
"entity_type": "EMAIL_ADDRESS",
"start": 13,
"end": 31,
"score": 0.99
},
{
"entity_type": "US_SSN",
"start": 42,
"end": 54,
"score": 0.99
}
]
}
/anonymize
Redact PII from text
POST /api/presidio/anonymize
Authorization: Bearer KEY
Content-Type: application/json
{
"text": "My email is john@example.com and SSN is 123-45-6789",
"language": "en",
"analyzer_results": [...],
"operators": {
"DEFAULT": {
"type": "mask",
"chars_to_mask": 4
},
"US_SSN": {
"type": "mask",
"chars_to_mask": 9
}
}
}
Response:
{
"text": "My email is ████████@example.com and SSN is █████-6789"
}
/batch_anonymize
Process multiple texts in parallel
POST /api/presidio/batch_anonymize
Authorization: Bearer KEY
Content-Type: application/json
{
"texts": [
"SSN: 123-45-6789",
"Email: alice@test.com",
"Phone: 555-123-4567"
],
"language": "en",
"method": "mask"
}
Response:
{
"results": [
{ "original": "SSN: 123-45-6789", "anonymized": "SSN: █████-6789" },
{ "original": "Email: alice@test.com", "anonymized": "Email: █████@test.com" },
{ "original": "Phone: 555-123-4567", "anonymized": "Phone: ███-123-4567" }
]
}
/scan_file
Upload and scan PDF, DOCX, XLSX
POST /api/presidio/scan_file
Authorization: Bearer KEY
Content-Type: multipart/form-data
file:
language: en
Response:
{
"file_name": "contract.pdf",
"file_type": "pdf",
"pii_count": 47,
"entities": [
{ "entity_type": "EMAIL_ADDRESS", "count": 12, "confidence": 0.98 },
{ "entity_type": "US_SSN", "count": 3, "confidence": 0.99 },
{ "entity_type": "CREDIT_CARD", "count": 5, "confidence": 0.97 }
]
}
/get_entities
List all 285+ available entity types
GET /api/presidio/get_entities?language=en&domain=healthcare
Authorization: Bearer KEY
Response:
{
"entities": [
{ "type": "US_SSN", "category": "IDENTIFIER", "description": "US Social Security Number" },
{ "type": "EMAIL_ADDRESS", "category": "CONTACT", "description": "Email addresses" },
{ "type": "CREDIT_CARD", "category": "FINANCIAL", "description": "Credit card numbers" },
{ "type": "MEDICAL_LICENSE", "category": "HEALTHCARE", "description": "Medical license number" },
...
],
"total": 285,
"language": "en",
"domain_filtered": "healthcare"
}
/estimate
Estimate token cost before processing
POST /api/presidio/estimate
Authorization: Bearer KEY
Content-Type: application/json
{
"text_length": 5000,
"entities_count": 15,
"method": "mask"
}
Response:
{
"estimated_tokens": 42,
"estimated_cost_usd": 0.021,
"processing_time_ms": 180,
"currency": "USD"
}
Code Examples
Python
import requests
response = requests.post(
'https://anonym.legal/api/presidio/analyze',
headers={
'Authorization': 'Bearer YOUR_KEY'
},
json={
'text': 'SSN: 123-45-6789',
'language': 'en'
}
)
results = response.json()['results']
Node.js (Fetch)
const response = await fetch(
'https://anonym.legal/api/presidio/analyze',
{
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
text: 'SSN: 123-45-6789',
language: 'en'
})
}
);
const data = await response.json();
cURL
curl -X POST \
https://anonym.legal/api/presidio/analyze \
-H 'Authorization: Bearer YOUR_KEY' \
-H 'Content-Type: application/json' \
-d '{
"text": "SSN: 123-45-6789",
"language": "en"
}'
Error Handling
401 Unauthorized
Invalid or missing API key. Check token in Authorization header.
400 Bad Request
Invalid request body. Check JSON syntax and required fields.
429 Too Many Requests
Rate limit exceeded. Wait before retrying. Check Retry-After header.
500 Server Error
Unexpected error. Retry with exponential backoff. Contact support if persistent.
503 Service Unavailable
Maintenance or regional outage. Retry on different endpoint. Check status page.
504 Gateway Timeout
Request took too long. Consider batch size or file size. Contact support.
Pricing Model
Token Consumption
- 1 token = 1 entity detected
- Analyze: 1 token per text
- Anonymize: 1 token per entity
- Batch: volume pricing -50%
- Minimum: 100 tokens/request
Free Tier
- 200 tokens free monthly
- Up to 1K requests/month
- Public docs access
- Community support
- No credit card required
Watch the API In Action
See PII detection and anonymization via REST API and MCP Server
Also from anonym.legal