获取用量
GET /v1/usage
获取已认证用户当前计费周期的提取用量。使用此端点监控消耗情况,避免超出计划限额。
试一试
在 Swagger UI 中交互式测试此端点。
需要认证
在 Authorization 头中包含您的 API 密钥。
请求
请求头
| 头 | 值 | 必需 |
|---|---|---|
Authorization | Bearer <token> | 是 |
此端点不接受查询参数或请求体。
代码示例
bash
curl https://api.docmap.io/v1/usage \
-H "Authorization: Bearer dm_live_abc123def456ghi789jkl012mno345"typescript
const apiKey = process.env.DOCMAP_API_KEY
const response = await fetch('https://api.docmap.io/v1/usage', {
headers: { 'Authorization': `Bearer ${apiKey}` },
})
const { data } = await response.json()
console.log(`${data.usage} / ${data.limit} extractions used (${data.plan} plan)`)python
import requests
api_key = "dm_live_abc123def456ghi789jkl012mno345"
response = requests.get(
"https://api.docmap.io/v1/usage",
headers={"Authorization": f"Bearer {api_key}"},
)
data = response.json()["data"]
print(f"{data['usage']} / {data['limit']} extractions used ({data['plan']} plan)")响应
状态码:200 OK
响应体包含在 data 对象中。
字段
| 字段 | 类型 | 描述 |
|---|---|---|
plan | string | 用户当前的计划:free、starter、core 或 pro。 |
usage | number | 当前计费周期已消耗的提取次数。 |
limit | number | 当前计划允许的最大提取次数。 |
periodKey | string | 当前计费周期,格式为 YYYY-MM。 |
示例
json
{
"data": {
"plan": "starter",
"usage": 142,
"limit": 500,
"periodKey": "2024-11"
}
}错误
| 状态码 | 错误码 | 描述 |
|---|---|---|
401 | UNAUTHORIZED | 缺少、无效或已过期的 API 密钥/令牌。 |
