Referencia de API
Integre la anonimización en sus aplicaciones
API REST completa para la detección y anonimización programática de PII.
URL Base
https://anonymize.today/apiTodos los puntos finales de la API son relativos a esta URL base. Por ejemplo, el punto final de análisis es https://anonymize.today/api/presidio/analyze.
Autenticación
Autentique las solicitudes de API utilizando tokens Bearer:
Authorization: Bearer YOUR_API_TOKENObteniendo un Token de API
- Inicie sesión en su cuenta de anonymize.today
- Vaya a Configuración → Cuenta → Tokens de API
- Haga clic en Generar Nuevo Token
- Copie y almacene su token de forma segura (no se mostrará nuevamente)
Nota de Seguridad
Nunca exponga su token de API en código del lado del cliente o en repositorios públicos. Utilice variables de entorno y solicitudes del lado del servidor.
Token en Solicitudes
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ímites de Tasa
| Tipo de Punto Final | Límite de Tasa | Permiso de ráfaga: 10 solicitudes |
|---|---|---|
| Authentication | 3 requests/second | 5 requests |
| Analysis & Anonymization | 30 requests/second | 50 requests |
| Presets & Settings | 10 requests/second | 20 requests |
Cuando se limita la tasa, la API devuelve 429 Demasiadas Solicitudes con un encabezado Retry-After que indica cuándo puede volver a intentar.
Puntos Finales Principales
Analizar Texto
Detectar entidades PII en el texto. Devuelve posiciones y tipos de entidades detectadas.
Anonimizar Texto
Anonimizar entidades PII detectadas utilizando varios operadores.
Desanonimizar Texto
Restaurar entidades encriptadas a sus valores originales utilizando la misma clave de encriptación.
Operadores de Anonimización
| Operador | Descripción | Reversible | Ejemplo |
|---|---|---|---|
| replace | Reemplazar con marcador de posición | No | John → [PERSON] |
| mask | Enmascarar parcialmente caracteres | No | john@email.com → j***@email.com |
| redact | Eliminar completamente | No | John → (empty) |
| hash | Hash SHA-256 unidireccional | No | John → a3f2b1c4... |
| encrypt | Encriptación AES-256-GCM | Yes | John → [ENC:...] |
Configuraciones de 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 Preajustes
Tipos de Entidades
anonymize.today admite 256 tipos de entidades en 10 categorías:
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
Vea la lista completa de tipos de entidades en la documentación de Preajustes. Presets documentation.
Idiomas Soportados
La API admite 27 idiomas para el reconocimiento de PII:
| Código | 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 |
Idiomas adicionales: Rumano, Griego, Croata, Esloveno, Macedonio, Sueco, Danés, Noruego, Finés, Ucraniano, Lituano, Catalán
Manejo de Errores
Códigos de estado HTTP estándar:
| Estado | Significado | Descripción |
|---|---|---|
| 200 | OK | Request succeeded |
| 201 | Created | Resource created successfully |
| 400 | Bad Request | 400 - Solicitud Incorrecta (parámetros inválidos) |
| 401 | Unauthorized | 401 - No Autorizado (token inválido o faltante) |
| 402 | Payment Required | Insufficient tokens |
| 403 | Forbidden | Access denied to resource |
| 404 | Not Found | Resource not found |
| 429 | Too Many Requests | 429 - Límite de Tasa (demasiadas solicitudes) |
| 500 | Internal Error | 500 - Error del Servidor (contactar soporte) |
Formato de Respuesta de Error
{
"error": {
"code": "INSUFFICIENT_TOKENS",
"message": "You need 5 tokens but only have 2 remaining",
"details": {
"required": 5,
"available": 2
}
}
}Ejemplos Completos
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 actualización: marzo de 2026