認証
はじめに

認証

Handelsregister AI APIは2つの認証方法をサポートしています:APIキーとBearerトークン。両方の方法はすべてのAPIエンドポイントで機能します。

認証方法

x-api-key: YOUR_API_KEY ヘッダー経由のAPIキー: サーバー間統合と本番環境での使用に推奨
?api_key=YOUR_API_KEY クエリパラメータ経由のAPIキー: クイックテストと下位互換性のためのみ
Authorization: Bearer YOUR_TOKEN Bearerトークン: 細かいアクセス制御、トークンの有効期限、強化されたセキュリティが必要なアプリケーションに最適

APIキー認証の例

x-api-keyヘッダーの使用(推奨)
curl -X GET "https://handelsregister.ai/api/v1/search-organizations?q=company" \
     -H "x-api-key: YOUR_API_KEY"
# Using query parameter (legacy)
curl "https://handelsregister.ai/api/v1/fetch-organization?api_key=YOUR_API_KEY&q=company"

# Using x-api-key header (recommended)
curl -X GET "https://handelsregister.ai/api/v1/fetch-organization?q=company" \
     -H "x-api-key: YOUR_API_KEY"

Bearerトークン管理

APIトークンの作成

curl -X POST "https://handelsregister.ai/api/v1/auth/tokens/create" \
     -H "x-api-key: YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
       "token_name": "My Application",
       "abilities": ["*"],
       "expires_at": "2026-01-01 00:00:00"
     }'

レスポンスにはBearerトークンが含まれます。安全に保管してください!

Bearerトークンの使用

curl -X GET "https://handelsregister.ai/api/v1/search-organizations?q=company" \
     -H "Authorization: Bearer YOUR_API_TOKEN"

トークン管理エンドポイント

POST /api/v1/auth/tokens/create 新しいトークンを作成
GET /api/v1/auth/tokens すべてのトークンを一覧表示
DELETE /api/v1/auth/tokens/{id} 特定のトークンを取り消す
DELETE /api/v1/auth/tokens すべてのトークンを取り消す