itecdn 5.x / 用户 API
查询套餐用量
GET
/v1/user-package/{package_id}/usage查询指定用户套餐当前已使用的域名、主域名、HTTP 非标准端口、四层转发端口和流量。普通用户只能查询自己的套餐;管理员可查询任意用户套餐。
身份认证
access-token
api-key + api-secret
认证定义
{
"AccessToken": {
"type": "apiKey",
"in": "header",
"name": "access-token",
"description": "通过登录接口获得的短期访问令牌。"
},
"ApiKey": {
"type": "apiKey",
"in": "header",
"name": "api-key",
"description": "API Key;必须和 api-secret 同时发送。"
},
"ApiSecret": {
"type": "apiKey",
"in": "header",
"name": "api-secret",
"description": "API Secret;必须和 api-key 同时发送。"
}
}请求参数
| 参数 | 位置 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|---|
package_id | path | integer | 必填 | 要查询用量的用户套餐 ID,必须存在且当前用户有权限查看。 完整参数定义 |
响应
HTTP 200
请求已被处理。成功时返回套餐资源用量;套餐不存在或无权限时仍返回 HTTP 200。该接口成功响应不包含 msg 或 count 字段。
application/json
object
| 字段 | 类型 | 必填 | 说明与约束 | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
code | integer | 必填 | 业务状态码;成功为 0。 约束 / 默认值 / 示例 | ||||||||||||||||||||||||
data | object | 必填 | 用户套餐当前资源用量。 约束 / 默认值 / 示例展开字段结构用户套餐当前资源用量。
|
完整 Schema
{
"type": "object",
"required": [
"code",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "业务状态码;成功为 0。",
"example": 0
},
"data": {
"type": "object",
"description": "用户套餐当前资源用量。",
"required": [
"domain_usage",
"main_domain_usage",
"http_port_usage",
"stream_port_usage",
"traffic_usage"
],
"properties": {
"domain_usage": {
"type": "integer",
"minimum": 0,
"description": "已使用域名数量。"
},
"main_domain_usage": {
"type": "integer",
"minimum": 0,
"description": "已使用主域名数量。"
},
"http_port_usage": {
"type": "integer",
"minimum": 0,
"description": "已使用 HTTP 非标准端口数量。"
},
"stream_port_usage": {
"type": "integer",
"minimum": 0,
"description": "已使用四层转发端口数量。"
},
"traffic_usage": {
"type": "integer",
"minimum": 0,
"description": "已使用流量,单位由服务端用量统计函数确定。"
}
}
}
}
}示例
{
"code": 0,
"data": {
"domain_usage": 3,
"main_domain_usage": 2,
"http_port_usage": 1,
"stream_port_usage": 1,
"traffic_usage": 1073741824
}
}查询成功
{
"code": 0,
"data": {
"domain_usage": 3,
"main_domain_usage": 2,
"http_port_usage": 1,
"stream_port_usage": 1,
"traffic_usage": 1073741824
}
}套餐不存在
{
"code": "user_package_usage-1",
"msg": "套餐不存在",
"data": ""
}cURL 示例
根据文档生成;请替换主控地址、路径参数和凭证,并按上表补充查询参数。
curl --request GET \
"https://master.example.invalid/v1/user-package/{package_id}/usage" \
--header "access-token: YOUR_ACCESS_TOKEN"