/v1/account

account

账户:通过 API 查看余额、用量、积分订阅和 API 密钥。

费用和限制

费用和限制
项目 积分
读取账户、余额、用量和积分订阅 免费

限制:每分钟 30 次请求。 创建、更新和删除:每分钟 10 次。

端点

方法
方法 路径 用途 访问
GET /v1/account 你的账户。 API 密钥
GET /v1/account/credits 余额和到期日期。 API 密钥
GET /v1/account/usage 某期间的用量汇总。 API 密钥
GET /v1/account/usage/transactions 单个请求及其费用。 API 密钥
GET /v1/account/subscription 你的积分订阅。 API 密钥
GET /v1/account/api-keys 你的 API 密钥。 API 密钥
POST /v1/account/api-keys 新的 API 密钥。 管理员令牌
DELETE /v1/account/api-keys/{id} 删除 API 密钥。 管理员令牌
POST /v1/auth/tokens/create 创建 Bearer 令牌。 API 密钥
GET · DELETE /v1/auth/tokens 列出和撤销 Bearer 令牌。 API 密钥

账户

curl -G "https://handelsregister.ai/api/v1/account" \
  -H "x-api-key: YOUR_API_KEY"
1{2  "account": {3    "id": 2,4    "name": "Max Mustermann",5    "email": "[email protected]",6    "email_verified": true,7    "language": "de",8    "plan": "max",9    "member_since": "2026-09-02T17:07:10+00:00"10  },11  "meta": {12    "request_credit_cost": 0,13    "credits_remaining": 14514  }15}
200 · 使用 Max 的账户的示例响应

余额

curl -G "https://handelsregister.ai/api/v1/account/credits" \
  -H "x-api-key: YOUR_API_KEY"
字段
字段 含义
balance.total 你的总余额。
balance.subscription 来自积分订阅的积分,包括更换套餐时结转的积分(rollover)。
balance.purchased 充值积分和初始积分。
next_expiry 下一批到期的积分,含 amount 和 expires_at。没有积分到期时为 null。
breakdown 每次发放的积分,含剩余数量 amount、来源 source 和到期日 valid_until。source 为 subscription、rollover、purchase 或 registration。
1{2  "balance": {3    "total": 145,4    "subscription": 0,5    "purchased": 1456  },7  "next_expiry": null,8  "meta": {9    "request_credit_cost": 0,10    "credits_remaining": 14511  }12}
200 · 示例响应:一个账户的余额
如需余额不足提醒,请定期查询 balance.total。这不收费。

用量

curl -G "https://handelsregister.ai/api/v1/account/usage" \
  -H "x-api-key: YOUR_API_KEY" \
  --data-urlencode 'from=2026-11-01' \
  --data-urlencode 'group_by=day'
参数
名称 类型 说明 示例
fromQuery 字符串可选 开始时间,YYYY-MM-DD 或 ISO 8601。省略时:月初。 2026-11-01
toQuery 字符串可选 结束时间,包含当日。纯日期计至当天结束。省略时:当前时间。 –
group_byQuery 字符串可选 省略时,API 将最长 92 天的期间按天分组,更长的按月分组。取值: day, month day
1{2  "period": {3    "from": "2026-11-01T00:00:00+00:00",4    "to": "2026-11-01T07:54:44+00:00"5  },6  "totals": {7    "requests": 80,8    "credits_used": 3209  },10  "by_endpoint": [11    {12      "endpoint": "/api/v1/signals",13      "requests": 7,14      "credits_used": 14015    },16    {17      "endpoint": "/api/v1/fetch-organization",18      "requests": 25,19      "credits_used": 12020    },21    {22      "endpoint": "/api/v1/search-companies",23      "requests": 47,24      "credits_used": 4025    },26    {27      "endpoint": "/api/v1/signals/e23c12835d697c00512944ebdfb8260f",28      "requests": 1,29      "credits_used": 2030    }31  ],32  "series": {33    "group_by": "day",34    "buckets": [35      {36        "date": "2026-11-01",37        "requests": 80,38        "credits_used": 32039      }40    ]41  },42  "meta": {43    "request_credit_cost": 0,44    "credits_remaining": 14545  }46}
200 · 示例响应:某一天的用量

单个请求

curl -G "https://handelsregister.ai/api/v1/account/usage/transactions" \
  -H "x-api-key: YOUR_API_KEY" \
  --data-urlencode 'per_page=3'
参数
名称 类型 说明 示例
fromQuery 字符串可选 开始时间,YYYY-MM-DD 或 ISO 8601。省略时:月初。 –
toQuery 字符串可选 结束时间,包含当日。纯日期计至当天结束。省略时:当前时间。 –
endpointQuery 字符串可选 仅限带有该确切标签的请求,与 endpoint 中的写法一致。 –
per_pageQuery 整数可选 每页条目数。API 会将更大的值降为 100。默认值: 25限制: 至少 1 3
cursorQuery 字符串可选 上一页的值 pagination.next_cursor,用于获取下一页。 –
1{2  "transactions": [3    {4      "id": 1116,5      "endpoint": "/api/v1/search-companies",6      "credits": 1,7      "parameters": {8        "q": "",9        "ai_search": false,10        "filters": {11          "postal_code": "91710",12          "active": true13        },14        "sort": null,15        "order": null,16        "status": 200,17        "search_type": "standard"18      },19      "created_at": "2026-11-01T07:55:02+00:00",20      "api_key_id": 1021    },22    {23      "id": 1115,24      "endpoint": "/api/v1/search-companies",25      "credits": 1,26      "parameters": {27        "q": "",28        "ai_search": false,29        "filters": {30          "postal_code": "91710",31          "active": true32        },33        "sort": null,34        "order": null,35        "status": 200,36        "search_type": "standard"37      },38      "created_at": "2026-11-01T07:55:01+00:00",39      "api_key_id": 1040    },41    {42      "id": 1114,43      "endpoint": "/api/v1/search-companies",44      "credits": 1,45      "parameters": {46        "q": "",47        "ai_search": false,48        "filters": {49          "industry_code": "62.1"50        },51        "sort": null,52        "order": null,53        "status": 200,54        "search_type": "standard"55      },56      "created_at": "2026-11-01T07:55:00+00:00",57      "api_key_id": 1058    }59  ],60  "pagination": {61    "per_page": 3,62    "next_cursor": "eyJjcmVhdGVkX2F0IjoiMjAyNi0xMS0wMSAwNzo1NTowMCIsImlkIjoxMTE0LCJfcG9pbnRzVG9OZXh0SXRlbXMiOnRydWV9"63  },64  "period": {65    "from": "2026-11-01T00:00:00+00:00",66    "to": "2026-11-01T07:55:02+00:00"67  },68  "meta": {69    "request_credit_cost": 0,70    "credits_remaining": 14571  }72}
200 · 示例响应:最新的三个请求

积分订阅

curl -G "https://handelsregister.ai/api/v1/account/subscription" \
  -H "x-api-key: YOUR_API_KEY"
1{2  "subscription": {3    "plan": "max",4    "status": "active",5    "billing_interval": "month",6    "cancel_at_period_end": false,7    "current_period_start": "2026-10-26T21:51:51+00:00",8    "current_period_end": "2026-11-26T21:51:51+00:00",9    "trial_ends_at": null,10    "canceled_at": null,11    "features": {12      "credits_per_month": 75000,13      "bonus_percentage": 15,14      "non_expiring_credits": true,15      "support_level": "priority"16    }17  },18  "meta": {19    "request_credit_cost": 0,20    "credits_remaining": 14521  }22}
200 · 示例响应:有效的 Max 积分订阅

管理 API 密钥

curl -G "https://handelsregister.ai/api/v1/account/api-keys" \
  -H "x-api-key: YOUR_API_KEY"
1{2  "api_keys": [3    {4      "id": 10,5      "key_last_8": "Ab12Cd34",6      "is_current": true,7      "created_at": "2026-11-01T04:17:31+00:00",8      "last_used_at": "2026-11-01T07:55:12+00:00",9      "usage_last_30d": {10        "requests": 97,11        "credits_used": 41112      }13    }14  ],15  "total": 1,16  "meta": {17    "request_credit_cost": 0,18    "credits_remaining": 14519  }20}
200 · 示例响应:一个账户的 API 密钥
curl -X POST "https://handelsregister.ai/api/v1/account/api-keys" \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN"
1{2  "api_key": {3    "id": 13,4    "key": "…",5    "created_at": "2026-11-01T08:32:00+00:00"6  },7  "meta": {8    "message": "Store this key securely. It grants full data access to this account.",9    "request_credit_cost": 0,10    "credits_remaining": 14511  }12}
201 · 示例响应:一个新的 API 密钥,此处已缩短

Bearer 令牌

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": "CRM-Sync",
    "abilities": [
        "api:data",
        "account:read"
    ]
}'
参数
名称 类型 说明 示例
token_nameBody 字符串必填 用于识别令牌的名称,例如你的应用名称。限制: 最多 255 个字符 CRM-Sync
abilitiesBody string 列表可选 权限列表。省略时,令牌获得用于数据端点的 api:data 和用于账户端点的 account:read。monitoring:manage 允许更改监控。默认值: ["*"] ["api:data","account:read"]
expires_atBody 字符串 (date-time)可选 将来的到期日期。省略时,令牌在你撤销之前一直有效。 –
1{2  "token": "…",3  "name": "CRM-Sync",4  "abilities": [5    "api:data",6    "account:read"7  ],8  "expires_at": null,9  "created_at": "2026-11-01T08:31:26.000000Z",10  "meta": {11    "message": "Token created successfully. Store this token securely as it will not be shown again.",12    "credits_remaining": 14513  }14}
201 · 示例响应:一个新令牌,此处已缩短
DELETE /v1/auth/tokens 一次撤销所有令牌,包括管理员令牌。此后你需要新的管理员令牌才能管理密钥。

错误

错误
状态 原因 你可以怎么做
400 api_key 位于 URL 中。 在请求头 x-api-key 中发送密钥。
400 某个参数无效,例如日期、group_by 或过长的期间。 按 meta.message 的说明修正该值。
401 没有 API 密钥或令牌,或其无效。 在请求头 x-api-key 中发送密钥。
401 没有 API 密钥或密钥无效。Bearer 令牌在 /v1/auth 下不可用。 在请求头 x-api-key 中发送 API 密钥。
403 Bearer 令牌缺少权限 account:read。 使用 API 密钥或带 account:read 的令牌。
403 你账户的电子邮件地址尚未确认,或账户已被锁定。 打开确认邮件中的链接。如果账户被锁定,客服可以提供帮助。
403 此调用需要管理员令牌。API 密钥不够,其他令牌也不行。 用 Authorization: Bearer 加管理员令牌发送。
404 没有此 ID 的密钥或令牌。 从列表中获取 ID。
422 已达到 API 密钥的最大数量(too_many_keys)。 删除一个旧密钥。
429 请求过多。 按 Retry-After 等待后重试。
500 某个值无效:token_name 缺失或过长,abilities 不是列表,或 expires_at 不在将来。 修正这些值。使用 Accept: application/json 时,错误以 JSON 返回。
1{2  "error": "invalid_request",3  "meta": {4    "message": "'group_by' must be one of: day, month.",5    "request_credit_cost": 0,6    "credits_remaining": 1457  }8}
400 · group_by 的值无效