itecdn 5.x / 用户 API
查询流量套餐
GET
/v1/traffic-packages分页查询流量包。普通用户只能看到已启用的流量包;管理员可通过 enable 查询指定启用状态。结果按流量包 ID 倒序返回,并带出可绑定套餐名称。
身份认证
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 同时发送。"
}
}请求参数
| 参数 | 位置 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|---|
page | query | integer | 可选 | 页码,必须为数字;未传时为 1。 完整参数定义 |
limit | query | integer | 可选 | 每页数量,必须为数字;未传时为 10,传 0 表示不分页。 完整参数定义 |
enable | query | integer | 可选 | 管理员可选。按启用状态筛选;普通用户始终仅返回启用的流量包。 完整参数定义 |
响应
HTTP 200
请求已被处理。成功时返回流量包列表和总数;页码或每页数量格式错误时也返回 HTTP 200,并在业务码中说明原因。
application/json
object
| 字段 | 类型 | 必填 | 说明与约束 | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
code | integer | 必填 | 业务状态码;成功为 0。 约束 / 默认值 / 示例 | ||||||||||||||||||||||||||||||||||||||||||||
count | integer | 必填 | 符合筛选条件的流量包总数。 约束 / 默认值 / 示例 | ||||||||||||||||||||||||||||||||||||||||||||
data | array <object> | 必填 | 流量包列表。 展开字段结构流量包列表。 数组元素 · object
|
完整 Schema
{
"type": "object",
"required": [
"code",
"count",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "业务状态码;成功为 0。",
"example": 0
},
"count": {
"type": "integer",
"minimum": 0,
"description": "符合筛选条件的流量包总数。",
"example": 2
},
"data": {
"type": "array",
"description": "流量包列表。",
"items": {
"type": "object",
"required": [
"id",
"name",
"amount",
"valid_days",
"price",
"enable"
],
"properties": {
"id": {
"type": "integer",
"description": "流量包 ID。"
},
"name": {
"type": "string",
"description": "流量包名称。"
},
"des": {
"type": "string",
"description": "备注。"
},
"amount": {
"type": "string",
"description": "流量额度,格式为数字加 GB、TB 或 PB。"
},
"bind_package": {
"type": "string",
"nullable": true,
"description": "可绑定套餐 ID 的逗号分隔字符串。"
},
"bind_package_name": {
"type": "string",
"nullable": true,
"description": "可绑定套餐名称的逗号分隔字符串。"
},
"valid_days": {
"type": "integer",
"description": "流量包有效天数。"
},
"price": {
"type": "integer",
"description": "价格,单位为系统最小货币单位。"
},
"enable": {
"type": "integer",
"enum": [
0,
1
],
"description": "启用状态。"
},
"create_at": {
"type": "string",
"description": "创建时间,格式为 YYYY-MM-DD HH:mm:ss。"
}
}
}
}
}
}示例
{
"code": 0,
"count": 1,
"data": [
{
"id": 5,
"name": "100GB 流量包",
"des": "月度加油包",
"amount": "100GB",
"bind_package": "1,2",
"bind_package_name": "标准套餐,高级套餐",
"valid_days": 30,
"price": 1000,
"enable": 1,
"create_at": "2026-01-01 12:00:00"
}
]
}查询成功
{
"code": 0,
"count": 1,
"data": [
{
"id": 5,
"name": "100GB 流量包",
"des": "月度加油包",
"amount": "100GB",
"bind_package": "1,2",
"bind_package_name": "标准套餐,高级套餐",
"valid_days": 30,
"price": 1000,
"enable": 1,
"create_at": "2026-01-01 12:00:00"
}
]
}页码格式错误
{
"code": "traffic_package-27",
"msg": "page参数格式不正确",
"data": ""
}cURL 示例
根据文档生成;请替换主控地址、路径参数和凭证,并按上表补充查询参数。
curl --request GET \
"https://master.example.invalid/v1/traffic-packages" \
--header "access-token: YOUR_ACCESS_TOKEN"