common.skipToContent

APIリファレンス

アプリケーションに匿名化を統合

プログラムによるPII検出と匿名化のための完全なREST API。


ベースURL

https://anonymize.today/api

すべてのAPIエンドポイントはこのベースURLに対して相対的です。例えば、分析エンドポイントは https://anonymize.today/api/presidio/analyze.


認証

Bearerトークンを使用してAPIリクエストを認証します:

Authorization: Bearer YOUR_API_TOKEN

APIトークンの取得

  1. anonymize.todayアカウントにサインインします
  2. 設定 → アカウント → APIトークンに移動します
  3. 新しいトークンを生成をクリックします
  4. トークンをコピーして安全に保管します(再表示されません)

セキュリティノート

クライアント側のコードや公開リポジトリでAPIトークンを公開しないでください。環境変数とサーバー側のリクエストを使用してください。

リクエスト内のトークン

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"]}'

レート制限

エンドポイントタイプレート制限バースト許可: 10リクエスト
Authentication3 requests/second5 requests
Analysis & Anonymization30 requests/second50 requests
Presets & Settings10 requests/second20 requests

レート制限がかかると、APIは429 Too Many Requestsを返し、リトライ可能な時間を示すRetry-Afterヘッダーが含まれます。


コアエンドポイント

テキストの分析

テキスト内のPIIエンティティを検出します。検出されたエンティティの位置とタイプを返します。

テキストの匿名化

さまざまなオペレーターを使用して検出されたPIIエンティティを匿名化します。

テキストの非匿名化

同じ暗号化キーを使用して暗号化されたエンティティを元の値に復元します。


匿名化オペレーター

オペレーター説明可逆
replaceプレースホルダーで置き換えNoJohn → [PERSON]
mask部分的に文字をマスクNojohn@email.com → j***@email.com
redact完全に削除NoJohn → (empty)
hash一方向SHA-256ハッシュNoJohn → a3f2b1c4...
encryptAES-256-GCM暗号化YesJohn → [ENC:...]

オペレーター設定

// 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


エンティティタイプ

anonymize.todayは10カテゴリにわたって256のエンティティタイプをサポートしています:

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

プリセットドキュメントでエンティティタイプの完全なリストを確認してください。 Presets documentation.


サポートされている言語

APIはPII認識のために27の言語をサポートしています:

コード言語エンジン
enEnglishspaCy
deGermanspaCy
esSpanishspaCy
frFrenchspaCy
itItalianspaCy
ptPortuguesespaCy
nlDutchspaCy
plPolishspaCy
ruRussianspaCy
jaJapanesespaCy
zhChinesespaCy
koKoreanspaCy
arArabicTransformer
hiHindiTransformer
trTurkishTransformer

追加の言語:ルーマニア語、ギリシャ語、クロアチア語、スロベニア語、マケドニア語、スウェーデン語、デンマーク語、ノルウェー語、フィンランド語、ウクライナ語、リトアニア語、カタルーニャ語


エラー処理

標準HTTPステータスコード:

ステータス意味説明
200OKRequest succeeded
201CreatedResource created successfully
400Bad Request400 - 不正リクエスト(無効なパラメータ)
401Unauthorized401 - 認証エラー(無効または欠落したトークン)
402Payment RequiredInsufficient tokens
403ForbiddenAccess denied to resource
404Not FoundResource not found
429Too Many Requests429 - レート制限(リクエストが多すぎる)
500Internal Error500 - サーバーエラー(サポートに連絡)

エラー応答形式

{
  "error": {
    "code": "INSUFFICIENT_TOKENS",
    "message": "You need 5 tokens but only have 2 remaining",
    "details": {
      "required": 5,
      "available": 2
    }
  }
}

完全な例

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

最終更新日: 2026年3月