Riferimento API
Integra l'anonimizzazione nelle tue applicazioni
API REST completa per il rilevamento e l'anonimizzazione programmatica delle PII.
URL di base
https://anonymize.today/apiTutti gli endpoint API sono relativi a questo URL di base. Ad esempio, l'endpoint di analisi è https://anonymize.today/api/presidio/analyze.
Autenticazione
Autenticare le richieste API utilizzando token Bearer:
Authorization: Bearer YOUR_API_TOKENOttenere un Token API
- Accedi al tuo account anonymize.today
- Vai su Impostazioni → Account → Token API
- Clicca su Genera Nuovo Token
- Copia e conserva in modo sicuro il tuo token (non verrà mostrato di nuovo)
Nota di Sicurezza
Non esporre mai il tuo token API nel codice client o nei repository pubblici. Utilizza variabili di ambiente e richieste lato server.
Token nelle Richieste
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"]}'Limiti di Richiesta
| Tipo di Endpoint | Limite di Richiesta | Limite di picco: 10 richieste |
|---|---|---|
| Authentication | 3 requests/second | 5 requests |
| Analysis & Anonymization | 30 requests/second | 50 requests |
| Presets & Settings | 10 requests/second | 20 requests |
Quando il limite è raggiunto, l'API restituisce 429 Troppi Richieste con un'intestazione Retry-After che indica quando puoi riprovare.
Endpoint Principali
Analizza Testo
Rileva entità PII nel testo. Restituisce posizioni e tipi di entità rilevate.
Anonymizza Testo
Anonymizza le entità PII rilevate utilizzando vari operatori.
De-anonymizza Testo
Ripristina le entità crittografate ai loro valori originali utilizzando la stessa chiave di crittografia.
Operatori di Anonimizzazione
| Operatore | Descrizione | Reversibile | Esempio |
|---|---|---|---|
| replace | Sostituisci con un segnaposto | No | John → [PERSON] |
| mask | Maschera parzialmente i caratteri | No | john@email.com → j***@email.com |
| redact | Rimuovi completamente | No | John → (empty) |
| hash | Hash SHA-256 unidirezionale | No | John → a3f2b1c4... |
| encrypt | Crittografia AES-256-GCM | Yes | John → [ENC:...] |
Configurazioni Operatore
// 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 Preset
Tipi di Entità
anonymize.today supporta 256 tipi di entità in 10 categorie:
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
Vedi l'elenco completo dei tipi di entità nella documentazione dei Preset. Presets documentation.
Lingue Supportate
L'API supporta 27 lingue per il riconoscimento PII:
| Codice | Lingua | Motore |
|---|---|---|
| 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 |
Lingue aggiuntive: Rumeno, Greco, Croato, Sloveno, Macedone, Svedese, Danese, Norvegese, Finlandese, Ucraino, Lituano, Catalano
Gestione degli Errori
Codici di stato HTTP standard:
| Stato | Significato | Descrizione |
|---|---|---|
| 200 | OK | Request succeeded |
| 201 | Created | Resource created successfully |
| 400 | Bad Request | 400 - Richiesta Errata (parametri non validi) |
| 401 | Unauthorized | 401 - Non Autorizzato (token non valido o mancante) |
| 402 | Payment Required | Insufficient tokens |
| 403 | Forbidden | Access denied to resource |
| 404 | Not Found | Resource not found |
| 429 | Too Many Requests | 429 - Limite di Richiesta (troppe richieste) |
| 500 | Internal Error | 500 - Errore del Server (contatta il supporto) |
Formato di Risposta di Errore
{
"error": {
"code": "INSUFFICIENT_TOKENS",
"message": "You need 5 tokens but only have 2 remaining",
"details": {
"required": 5,
"available": 2
}
}
}Esempi Completi
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
Ultimo aggiornamento: Marzo 2026