API Documentation

Quickstart Guide

このガイドでは、PII-Fi APIを使い始めるための手順を説明します。

💡 Prerequisites
  • APIキー(担当者から提供)
  • HTTPS通信が可能な環境
  • curl、Python 3.8+、またはNode.js 18+
⚠ デモ環境について

本ガイドで使用する api.pii-fi.com は性能テストやトライアル向けのデモ環境です。
本番環境ではお客様ごとに専用環境をご用意し、専用のエンドポイントを提供いたします。

Step 1: APIキーの確認

APIキーは以下の形式で提供されます。

pk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
⚠ Security

APIキーは安全に管理してください。公開リポジトリやクライアントサイドコードに含めないでください。

Step 2: 最初のPII検出

POST /api/detect
bash
curl -X POST https://api.pii-fi.com/api/detect \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "text": "田中太郎(090-1234-5678)のメールはtanaka@example.comです。"
  }'
python
import requests

API_KEY = "YOUR_API_KEY"
# デモ環境(本番環境では専用エンドポイントを提供)
BASE_URL = "https://api.pii-fi.com/api"

response = requests.post(
    f"{BASE_URL}/detect",
    headers={
        "Content-Type": "application/json",
        "Authorization": f"Bearer {API_KEY}"
    },
    json={
        "text": "田中太郎(090-1234-5678)のメールはtanaka@example.comです。"
    }
)

result = response.json()
print(f"マスキング済み: {result['deidentified_text']}")
print(f"検出数: {len(result['entities'])}")
javascript
const API_KEY = "YOUR_API_KEY";
// デモ環境(本番環境では専用エンドポイントを提供)
const BASE_URL = "https://api.pii-fi.com/api";

const response = await fetch(`${BASE_URL}/detect`, {
    method: "POST",
    headers: {
        "Content-Type": "application/json",
        "Authorization": `Bearer ${API_KEY}`
    },
    body: JSON.stringify({
        text: "田中太郎(090-1234-5678)のメールはtanaka@example.comです。"
    })
});

const result = await response.json();
console.log(`マスキング済み: ${result.deidentified_text}`);
console.log(`検出数: ${result.entities.length}`);

Step 4: 非識別化方式を選択

用途に応じて5種類の非識別化方式から選択できます。

replace(デフォルト)

PIIをタグ形式で置換します。

bash
curl -X POST https://api.pii-fi.com/api/detect \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{"text": "田中太郎です", "deidentification_type": "replace"}'

# 出力: <人名>です

mask

一部の文字を残してマスクします。

bash
curl -X POST https://api.pii-fi.com/api/detect \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{"text": "090-1234-5678に連絡", "deidentification_type": "mask"}'

# 出力: 090-****-5678に連絡

full_mask

すべての文字をマスクします。

bash
curl -X POST https://api.pii-fi.com/api/detect \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{"text": "田中太郎です", "deidentification_type": "full_mask"}'

# 出力: ****です

hash

ハッシュ値に置換します。

bash
curl -X POST https://api.pii-fi.com/api/detect \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{"text": "田中太郎です", "deidentification_type": "hash"}'

# 出力: JPII_PERSON_NAME_a1b2c3d4です

fake(LLMワークフロー推奨)

自然なダミーデータに置換します(復元可能)。

bash
curl -X POST https://api.pii-fi.com/api/detect \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "text": "田中太郎です",
    "deidentification_type": "fake",
    "include_mapping_info": true
  }'

# 出力: 山田花子です(+ 復元用マッピング情報)

Step 5: 特定のエンティティのみ検出

enabled_entities パラメータで検出するエンティティタイプを制限できます。

bash
# 電話番号とメールアドレスのみ検出(人名は無視)
curl -X POST https://api.pii-fi.com/api/detect \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "text": "田中太郎(090-1234-5678)のメールはtanaka@example.com",
    "enabled_entities": ["JPII_PHONE_NUMBER", "JPII_EMAIL_ADDRESS"]
  }'

# 出力: 田中太郎(<電話番号>)のメールは<メールアドレス>

Troubleshooting

リクエストがタイムアウトする

Content-Type: application/json ヘッダーが設定されているか確認してください。

401 Unauthorized

APIキーが正しいか確認してください。キーは pk_live_ で始まります。

422 Unprocessable Entity

リクエストパラメータを確認してください。エラーレスポンスの detail フィールドに詳細が記載されています。

Next Steps