作者: ·

强大的 REST API

匿名化 API 是一种编程端点,可在文本到达下游系统之前检测并移除其中的 PII。借助简单的端点、全面的文档和企业级的可靠性,您可以将其集成到任何应用程序中。

快速开始

几分钟内开始使用 API

安装我们的 SDK 并进行第一次 API 调用

  • 为您的语言安装 SDK
  • 从仪表板获取您的 API 令牌
  • 进行第一次匿名化请求
  • 集成到您的应用程序中
// Analyze text for PII
const response = await fetch('https://anonym.legal/api/presidio/analyze', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    text: 'Contact John Smith at john.smith@company.com',
    language: 'en'
  })
});

const results = await response.json();
// Returns detected entities with positions and confidence scores

可用端点

POST/api/presidio/analyze

Analyze text to detect PII entities. Returns entity types, positions, and confidence scores.

View documentation →
POST/api/presidio/anonymize

Anonymize detected PII using your chosen method. Returns anonymized text.

View documentation →
POST/api/presidio/batch

Process multiple texts in a single request (from the Basic plan, up to 5 texts). Business plans support up to 50 texts per batch.

View documentation →
POST/api/presidio/image

Detect or redact PII in a PNG/JPEG image (mode=analyze|redact). Redact mode supports solid-box, label-replace, or masked-character rendering per region.

View documentation →
GET/api/health

Check service status and runtime health. No authentication required.

Public endpoint

API 功能

JWT 认证

所有 API 调用的安全基于令牌的认证

速率限制

公平的速率限制,带有清晰的头信息。企业用户享有更高的限制

代码示例

多种编程语言的现成示例

Endpoint Reference

Complete REST documentation. All endpoints require Bearer token authentication unless noted.

Authentication

Every request requires a Bearer token in the Authorization header. Get your access token from Settings → Developer Access in the web app.

Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json

Endpoints

MethodEndpointDescription
POST/api/presidio/analyzeDetect PII entities in text
POST/api/presidio/anonymizeAnonymize detected PII entities
POST/api/presidio/batchProcess multiple files in one request
POST/api/presidio/imageDetect or redact PII in PNG/JPEG images (mode=analyze|redact)
GET/api/presidio/entitiesList supported entity types
GET/api/healthService health (no auth required)
GET/api/presetsList saved presets
POST/api/presetsCreate a new preset
PUT/api/presets/{id}Update a preset
DELETE/api/presets/{id}Delete a preset
GET/api/encryption-keysList encryption key metadata
GET/api/encryption-keys/{id}Get key details (add ?includeKey=true for value)

Request & Response Schemas

POST /api/presidio/analyze — Request

{
  "text": "John Smith lives at 123 Main St. SSN: 123-45-6789",
  "language": "en",
  "entities": ["PERSON", "LOCATION", "US_SSN"],
  "score_threshold": 0.5,
  "ad_hoc_recognizers": [
    {
      "entity_type": "EMPLOYEE_ID",
      "patterns": [{ "regex": "EMP-[0-9]{6}", "score": 0.9 }]
    }
  ]
}

POST /api/presidio/analyze — Response

{
  "entities": [
    { "entity_type": "PERSON", "text": "John Smith", "start": 0, "end": 10, "score": 0.95 },
    { "entity_type": "LOCATION", "text": "123 Main St", "start": 20, "end": 31, "score": 0.87 },
    { "entity_type": "US_SSN", "text": "123-45-6789", "start": 38, "end": 49, "score": 0.99 }
  ],
  "tokens_charged": 3,
  "language": "en"
}

POST /api/presidio/anonymize — Request with Operators

{
  "text": "John Smith, SSN 123-45-6789, email john@example.com",
  "language": "en",
  "operators": {
    "PERSON": { "type": "replace", "new_value": "<NAME>" },
    "US_SSN": { "type": "mask", "chars_to_mask": 5, "from_end": false },
    "EMAIL_ADDRESS": { "type": "hash", "hash_type": "SHA256" }
  }
}

POST /api/presidio/anonymize — Response

{
  "anonymized_text": "<NAME>, SSN ***-**-6789, email a3f2b8c1d4e5f6...",
  "entities_found": 3,
  "tokens_charged": 5,
  "replacements": [
    { "entity_type": "PERSON", "original": "John Smith", "replacement": "<NAME>" },
    { "entity_type": "US_SSN", "original": "123-45-6789", "replacement": "***-**-6789" },
    { "entity_type": "EMAIL_ADDRESS", "original": "john@example.com", "replacement": "a3f2b8c1..." }
  ]
}

POST /api/presidio/image — Request (multipart/form-data)

curl -X POST https://anonym.legal/api/presidio/image \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -F "file=@document.png" \
  -F "mode=redact" \
  -F "language=en" \
  -F "entities=[\"PERSON\",\"US_SSN\"]" \
  -F "operator=mask" \
  -F "mask_char=#"

POST /api/presidio/image — Response

// mode=analyze -> application/json (bounding boxes, not text offsets)
{
  "entities": [
    { "entity_type": "PERSON", "score": 0.95, "left": 120, "top": 80, "width": 140, "height": 24 }
  ],
  "processing_time": 0.83,
  "tokens_charged": 4
}

// mode=redact -> binary image/png body
// Content-Type: image/png
// X-Tokens-Charged: 4

Operator Reference

Configure per-entity anonymization using the operators field. Each entity type can use a different operator.

OperatorDescriptionParametersExample Output
replaceReplace with custom value or tokennew_value (string, max 100 chars)<PERSON_1>
redactPermanently removeNone[REDACTED]
hashOne-way hashhash_type: SHA256 | SHA512a3f2b8c1...
encryptAES reversible encryption with your keykey (16-32 chars)ENC:base64...
maskPartial character maskingchars_to_mask, masking_char, from_endJohn ****
keepKeep original (skip anonymization)NoneJohn Smith

Rate Limits & Token Costs

PlanMonthly TokensDeveloper Access
Free200—
Basic1,000REST endpoints
Pro4,000REST endpoints + MCP Server
Business10,000REST endpoints + MCP Server + Priority

Error Codes

CodeDescriptionResponse Format
400Invalid request (missing text, bad parameters){ "error": "Text is required" }
401Missing or invalid API token{ "error": "Unauthorized" }
403Feature not available on current plan{ "error": "Upgrade required" }
429Token balance exhausted or rate limited{ "error": "Insufficient tokens", "details": {...} }
500Internal server error{ "error": "Internal server error" }

今天开始构建

API 访问从 Basic 计划开始提供。Free 计划(网页应用中每 30 天周期 200 个令牌)不提供 API 访问。

Limitations / Important note

  • Rate limits and available endpoints depend on your plan; integrate retry/backoff for 429 responses.
  • Detection results are probabilistic confidence scores, not guarantees &mdash; validate before automated downstream use.
  • This documentation is informational and is not legal or compliance advice.

How we measure — our methodology