Referència API
Integra l'anonimització a les teves aplicacions
API REST completa per a la detecció i anonimització programàtica de PII.
URL base
https://anonymize.today/apiTots els punts d'API són relatius a aquesta URL base. Per exemple, el punt d'anàlisi és https://anonymize.today/api/presidio/analyze.
Autenticació
Autentica les sol·licituds API utilitzant tokens Bearer:
Authorization: Bearer YOUR_API_TOKENObtenint un token d'API
- Inicieu sessió al vostre compte d'anonymize.today
- Ves a Configuració → Compte → Tokens d'API
- Feu clic a Generar nou token
- Copia i emmagatzema el teu token de manera segura (no es mostrarà de nou)
Nota de seguretat
Mai exposeu el vostre token d'API en codi del costat del client o repositoris públics. Utilitzeu variables d'entorn i sol·licituds del costat del servidor.
Token en sol·licituds
TypeScript
const response = await fetch('https://anonymize.today/api/presidio/analyze', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.ANONYMIZE_API_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ text, entities }),
});Python
import os
import requests
headers = {
"Authorization": f"Bearer {os.environ['ANONYMIZE_API_TOKEN']}",
"Content-Type": "application/json"
}
response = requests.post(
"https://anonymize.today/api/presidio/analyze",
headers=headers,
json={"text": text, "entities": entities}
)cURL
curl -X POST https://anonymize.today/api/presidio/analyze \
-H "Authorization: Bearer $ANONYMIZE_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"text": "John Doe works at Acme Corp", "entities": ["PERSON", "ORGANIZATION"]}'Límits de Taxa
| Tipus de punt final | Límit de taxa | Permís de ràfega: 10 sol·licituds |
|---|---|---|
| Authentication | 3 requests/second | 5 requests |
| Analysis & Anonymization | 30 requests/second | 50 requests |
| Presets & Settings | 10 requests/second | 20 requests |
Quan es limita la taxa, l'API retorna 429 Massa sol·licituds amb un capçalera Retry-After que indica quan podeu tornar a provar.
Punts finals principals
Analitzar text
Detectar entitats PII en text. Retorna posicions i tipus d'entitats detectades.
Anonimitzar text
Anonimitza les entitats PII detectades utilitzant diversos operadors.
Desanonimitzar text
Restaura les entitats xifrades als seus valors originals utilitzant la mateixa clau de xifrat.
Operadors d'anonimització
| Operador | Descripció | Reversible | Exemple |
|---|---|---|---|
| replace | Substituir per un marcador de posició | No | John → [PERSON] |
| mask | Mascarar parcialment caràcters | No | john@email.com → j***@email.com |
| redact | Eliminar completament | No | John → (empty) |
| hash | Hash SHA-256 unidireccional | No | John → a3f2b1c4... |
| encrypt | Xifrat AES-256-GCM | Yes | John → [ENC:...] |
Configuracions d'operador
// Replace operator
{ "type": "replace", "new_value": "[PERSON]" }
// Mask operator
{
"type": "mask",
"masking_char": "*",
"chars_to_mask": 5,
"from_end": false
}
// Hash operator
{ "type": "hash", "hash_type": "sha256" }
// Encrypt operator (requires encryption key in user settings)
{ "type": "encrypt" }
// Redact operator
{ "type": "redact" }API de presets
Tipus d'entitats
anonymize.today suporta 256 tipus d'entitats en 10 categories:
Personal
PERSON, EMAIL_ADDRESS, PHONE_NUMBER
Financial
CREDIT_CARD, IBAN_CODE, SWIFT_CODE, CRYPTO
Location
LOCATION, ADDRESS, COORDINATES
Government
SSN, PASSPORT, DRIVER_LICENSE, NATIONAL_ID
Contact
URL, DOMAIN_NAME
Technical
IP_ADDRESS, MAC_ADDRESS
Temporal
DATE_TIME, AGE
Organizational
ORGANIZATION, JOB_TITLE
Medical
MEDICAL_LICENSE, HEALTH_ID
Custom
User-defined patterns
Veure la llista completa de tipus d'entitats a la documentació de Presets. Presets documentation.
Idiomes suportats
L'API suporta 27 idiomes per al reconeixement de PII:
| Codi | Idioma | Motor |
|---|---|---|
| en | English | spaCy |
| de | German | spaCy |
| es | Spanish | spaCy |
| fr | French | spaCy |
| it | Italian | spaCy |
| pt | Portuguese | spaCy |
| nl | Dutch | spaCy |
| pl | Polish | spaCy |
| ru | Russian | spaCy |
| ja | Japanese | spaCy |
| zh | Chinese | spaCy |
| ko | Korean | spaCy |
| ar | Arabic | Transformer |
| hi | Hindi | Transformer |
| tr | Turkish | Transformer |
Idiomes addicionals: romanès, grec, croat, eslovè, macedoni, suec, danès, noruec, finès, ucraïnès, lituà, català
Gestió d'Errors
Codis d'estat HTTP estàndard:
| Estat | Significat | Descripció |
|---|---|---|
| 200 | OK | Request succeeded |
| 201 | Created | Resource created successfully |
| 400 | Bad Request | 400 - Sol·licitud Incorrecta (paràmetres no vàlids) |
| 401 | Unauthorized | 401 - No Autoritzat (token no vàlid o absent) |
| 402 | Payment Required | Insufficient tokens |
| 403 | Forbidden | Access denied to resource |
| 404 | Not Found | Resource not found |
| 429 | Too Many Requests | 429 - Límit de Taxa (massa sol·licituds) |
| 500 | Internal Error | 500 - Error del Servidor (contacta amb el suport) |
Format de resposta d'error
{
"error": {
"code": "INSUFFICIENT_TOKENS",
"message": "You need 5 tokens but only have 2 remaining",
"details": {
"required": 5,
"available": 2
}
}
}Exemples Complets
TypeScript/Node.js
import fetch from 'node-fetch';
const API_BASE = 'https://anonymize.today/api';
const API_TOKEN = process.env.ANONYMIZE_API_TOKEN;
async function analyzeAndAnonymize(text: string) {
// Step 1: Analyze
const analyzeResponse = await fetch(`${API_BASE}/presidio/analyze`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
text,
entities: ['PERSON', 'EMAIL_ADDRESS', 'PHONE_NUMBER'],
language: 'en',
}),
});
const { results } = await analyzeResponse.json();
if (results.length === 0) {
return { text, anonymized: false };
}
// Step 2: Anonymize
const anonymizeResponse = await fetch(`${API_BASE}/presidio/anonymize`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
text,
analyzer_results: results,
anonymizers: {
DEFAULT: { type: 'replace', new_value: '[REDACTED]' },
},
}),
});
return anonymizeResponse.json();
}
// Usage
const result = await analyzeAndAnonymize('Contact John Doe at john@example.com');
console.log(result.text); // "Contact [REDACTED] at [REDACTED]"
Python
import os
import requests
API_BASE = "https://anonymize.today/api"
API_TOKEN = os.environ["ANONYMIZE_API_TOKEN"]
def analyze_and_anonymize(text: str) -> dict:
headers = {
"Authorization": f"Bearer {API_TOKEN}",
"Content-Type": "application/json"
}
# Step 1: Analyze
analyze_response = requests.post(
f"{API_BASE}/presidio/analyze",
headers=headers,
json={
"text": text,
"entities": ["PERSON", "EMAIL_ADDRESS", "PHONE_NUMBER"],
"language": "en"
}
)
results = analyze_response.json()["results"]
if not results:
return {"text": text, "anonymized": False}
# Step 2: Anonymize
anonymize_response = requests.post(
f"{API_BASE}/presidio/anonymize",
headers=headers,
json={
"text": text,
"analyzer_results": results,
"anonymizers": {
"DEFAULT": {"type": "replace", "new_value": "[REDACTED]"}
}
}
)
return anonymize_response.json()
# Usage
result = analyze_and_anonymize("Contact John Doe at john@example.com")
print(result["text"]) # "Contact [REDACTED] at [REDACTED]"
Related Documentation
Última actualització: març de 2026