Referință API
Integrează anonimizarea în aplicațiile tale
API REST complet pentru detectarea și anonimizarea PII programatic.
URL de bază
https://anonymize.today/apiToate punctele finale API sunt relative la această URL de bază. De exemplu, punctul final de analiză este https://anonymize.today/api/presidio/analyze.
Autentificare
Autentifică cererile API folosind token-uri Bearer:
Authorization: Bearer YOUR_API_TOKENObținerea unui token API
- Conectați-vă la contul dvs. anonymize.today
- Mergeți la Setări → Cont → Token-uri API
- Faceți clic pe Generați un token nou
- Copiați și stocați în siguranță token-ul dvs. (nu va fi afișat din nou)
Notă de securitate
Nu expuneți niciodată token-ul dvs. API în codul de client sau în repozitorii publice. Utilizați variabile de mediu și cereri de server.
Token în cereri
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"]}'Limite de Rată
| Tip de punct final | Limită de rată | Alocație de burst: 10 cereri |
|---|---|---|
| Authentication | 3 requests/second | 5 requests |
| Analysis & Anonymization | 30 requests/second | 50 requests |
| Presets & Settings | 10 requests/second | 20 requests |
Când este limitat, API-ul returnează 429 Prea multe cereri cu un header Retry-After care indică când puteți încerca din nou.
Puncte finale de bază
Analizați textul
Detectați entitățile PII în text. Returnează pozițiile și tipurile entităților detectate.
Anonimizare text
Anonimizați entitățile PII detectate folosind diferiți operatori.
Deanonimizare text
Restabiliți entitățile criptate la valorile lor originale folosind aceeași cheie de criptare.
Operatori de anonimizare
| Operator | Descriere | Reversibil | Exemplu |
|---|---|---|---|
| replace | Înlocuiți cu un placeholder | No | John → [PERSON] |
| mask | Mascați parțial caracterele | No | john@email.com → j***@email.com |
| redact | Eliminați complet | No | John → (empty) |
| hash | Hash SHA-256 unidirecțional | No | John → a3f2b1c4... |
| encrypt | Criptare AES-256-GCM | Yes | John → [ENC:...] |
Configurări operator
// 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 Presets
Tipuri de entități
anonymize.today suportă 256 de tipuri de entități în 10 categorii:
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
Consultați lista completă de tipuri de entități în documentația Presets. Presets documentation.
Limbi suportate
API-ul suportă 27 de limbi pentru recunoașterea PII:
| Cod | Limba | 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 |
Limbi suplimentare: română, greacă, croată, slovenă, macedoneană, suedeză, daneză, norvegiană, finlandeză, ucraineană, lituaniană, catalană
Gestionarea Erorilor
Coduri standard de stare HTTP:
| Status | Semnificație | Descriere |
|---|---|---|
| 200 | OK | Request succeeded |
| 201 | Created | Resource created successfully |
| 400 | Bad Request | 400 - Cerere Greșită (parametrii invalizi) |
| 401 | Unauthorized | 401 - Neautorizat (token invalid sau lipsă) |
| 402 | Payment Required | Insufficient tokens |
| 403 | Forbidden | Access denied to resource |
| 404 | Not Found | Resource not found |
| 429 | Too Many Requests | 429 - Limită de Rată (prea multe cereri) |
| 500 | Internal Error | 500 - Eroare de Server (contactează suportul) |
Formatul răspunsului de eroare
{
"error": {
"code": "INSUFFICIENT_TOKENS",
"message": "You need 5 tokens but only have 2 remaining",
"details": {
"required": 5,
"available": 2
}
}
}Exemple complete
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
Ultima actualizare: Martie 2026