入门指南
身份验证
Handelsregister AI API 支持两种身份验证方法: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 |
撤销所有令牌 |