common.skipToContent

Referință API

Integrează anonimizarea în aplicațiile tale

API REST complet pentru detectarea și anonimizarea PII programatic.


URL de bază

https://anonymize.today/api

Toate 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_TOKEN

Obținerea unui token API

  1. Conectați-vă la contul dvs. anonymize.today
  2. Mergeți la Setări → Cont → Token-uri API
  3. Faceți clic pe Generați un token nou
  4. 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 finalLimită de ratăAlocație de burst: 10 cereri
Authentication3 requests/second5 requests
Analysis & Anonymization30 requests/second50 requests
Presets & Settings10 requests/second20 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

OperatorDescriereReversibilExemplu
replaceÎnlocuiți cu un placeholderNoJohn → [PERSON]
maskMascați parțial caractereleNojohn@email.com → j***@email.com
redactEliminați completNoJohn → (empty)
hashHash SHA-256 unidirecționalNoJohn → a3f2b1c4...
encryptCriptare AES-256-GCMYesJohn → [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:

CodLimbaMotor
enEnglishspaCy
deGermanspaCy
esSpanishspaCy
frFrenchspaCy
itItalianspaCy
ptPortuguesespaCy
nlDutchspaCy
plPolishspaCy
ruRussianspaCy
jaJapanesespaCy
zhChinesespaCy
koKoreanspaCy
arArabicTransformer
hiHindiTransformer
trTurkishTransformer

Limbi suplimentare: română, greacă, croată, slovenă, macedoneană, suedeză, daneză, norvegiană, finlandeză, ucraineană, lituaniană, catalană


Gestionarea Erorilor

Coduri standard de stare HTTP:

StatusSemnificațieDescriere
200OKRequest succeeded
201CreatedResource created successfully
400Bad Request400 - Cerere Greșită (parametrii invalizi)
401Unauthorized401 - Neautorizat (token invalid sau lipsă)
402Payment RequiredInsufficient tokens
403ForbiddenAccess denied to resource
404Not FoundResource not found
429Too Many Requests429 - Limită de Rată (prea multe cereri)
500Internal Error500 - 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