Skip to content

获取用量

GET /v1/usage

获取已认证用户当前计费周期的提取用量。使用此端点监控消耗情况,避免超出计划限额。

试一试

Swagger UI 中交互式测试此端点。

需要认证

Authorization 头中包含您的 API 密钥。

请求

请求头

必需
AuthorizationBearer <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 对象中。

字段

字段类型描述
planstring用户当前的计划:freestartercorepro
usagenumber当前计费周期已消耗的提取次数。
limitnumber当前计划允许的最大提取次数。
periodKeystring当前计费周期,格式为 YYYY-MM

示例

json
{
  "data": {
    "plan": "starter",
    "usage": 142,
    "limit": 500,
    "periodKey": "2024-11"
  }
}

错误

状态码错误码描述
401UNAUTHORIZED缺少、无效或已过期的 API 密钥/令牌。

DocMap API 文档