itecdn 5.x用户文档
itecdn 5.x / 用户 API

查询用户流量套餐列表

GET/v1/user-traffic-packages

分页查询已购买的用户流量套餐。普通用户只能查看自己的流量套餐;管理员可按归属用户、流量套餐定义和启用状态筛选。结果按用户流量套餐 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 同时发送。"
  }
}

请求参数

参数位置类型必填说明与约束
pagequeryinteger可选

页码,必须为数字;未传时为 1。

完整参数定义
{
  "name": "page",
  "in": "query",
  "required": false,
  "schema": {
    "type": "integer",
    "minimum": 1,
    "default": 1,
    "example": 1
  },
  "description": "页码,必须为数字;未传时为 1。"
}
limitqueryinteger可选

每页数量,必须为数字;未传时为 10,传 0 表示不分页。

完整参数定义
{
  "name": "limit",
  "in": "query",
  "required": false,
  "schema": {
    "type": "integer",
    "minimum": 0,
    "default": 10,
    "example": 10
  },
  "description": "每页数量,必须为数字;未传时为 10,传 0 表示不分页。"
}
uidqueryinteger可选

管理员可选。按归属用户 ID 筛选;普通用户始终只能查询自己的流量套餐。

完整参数定义
{
  "name": "uid",
  "in": "query",
  "required": false,
  "schema": {
    "type": "integer",
    "minimum": 1,
    "example": 12
  },
  "description": "管理员可选。按归属用户 ID 筛选;普通用户始终只能查询自己的流量套餐。"
}
traffic_package_idqueryinteger可选

按流量套餐定义 ID 筛选,必须为数字。

完整参数定义
{
  "name": "traffic_package_id",
  "in": "query",
  "required": false,
  "schema": {
    "type": "integer",
    "minimum": 1,
    "example": 3
  },
  "description": "按流量套餐定义 ID 筛选,必须为数字。"
}
enablequeryinteger可选

按用户流量套餐启用状态筛选。

完整参数定义
{
  "name": "enable",
  "in": "query",
  "required": false,
  "schema": {
    "type": "integer",
    "enum": [
      0,
      1
    ],
    "example": 1
  },
  "description": "按用户流量套餐启用状态筛选。"
}

响应

HTTP 200

请求已被处理。成功时返回用户流量套餐列表及总数;页码、每页数量、用户 ID 或流量套餐 ID 格式无效时仍返回 HTTP 200。

application/json

object

字段类型必填说明与约束
codeinteger必填

业务状态码;成功为 0。

约束 / 默认值 / 示例
{
  "example": 0
}
countinteger必填

符合筛选条件的用户流量套餐总数。

约束 / 默认值 / 示例
{
  "minimum": 0,
  "example": 1
}
dataarray <object>必填

用户流量套餐列表。

展开字段结构

用户流量套餐列表。

数组元素 · object
字段类型必填说明与约束
idinteger必填

用户流量套餐 ID。

约束 / 默认值 / 示例
{
  "example": 21
}
uidinteger必填

归属用户 ID。

约束 / 默认值 / 示例
{
  "example": 12
}
user_namestring可选

归属用户名。

约束 / 默认值 / 示例
{
  "nullable": true,
  "example": "demo"
}
namestring必填

用户流量套餐名称。

约束 / 默认值 / 示例
{
  "example": "100 GB 加油包"
}
traffic_package_idinteger必填

流量套餐定义 ID。

约束 / 默认值 / 示例
{
  "example": 3
}
bind_packagestring可选

适用的基础套餐定义 ID,以英文逗号分隔;为空表示不限制。

约束 / 默认值 / 示例
{
  "nullable": true,
  "example": "2,3"
}
bind_package_namestring可选

适用基础套餐名称的聚合结果。

约束 / 默认值 / 示例
{
  "nullable": true,
  "example": "标准套餐,专业套餐"
}
amountstring必填

购买流量总量,单位为 GB、TB 或 PB。

约束 / 默认值 / 示例
{
  "example": "100GB"
}
usageinteger必填

已使用流量。

约束 / 默认值 / 示例
{
  "minimum": 0,
  "example": 1073741824
}
pricenumber可选

实际购买价格。

约束 / 默认值 / 示例
{
  "example": 10
}
orgin_pricenumber可选

优惠前购买价格。

约束 / 默认值 / 示例
{
  "example": 12
}
expirestring必填

流量套餐到期时间,格式 YYYY-MM-DD HH:mm:ss。

约束 / 默认值 / 示例
{
  "example": "2026-12-31 23:59:59"
}
create_atstring可选

创建时间,格式 YYYY-MM-DD HH:mm:ss。

约束 / 默认值 / 示例
{
  "example": "2026-01-01 00:00:00"
}
enableinteger必填

启用状态。

约束 / 默认值 / 示例
{
  "enum": [
    0,
    1
  ],
  "example": 1
}
reasonstring可选

禁用原因;启用时通常为空。

约束 / 默认值 / 示例
{
  "nullable": true,
  "example": null
}
完整 Schema
{
  "type": "object",
  "required": [
    "code",
    "count",
    "data"
  ],
  "properties": {
    "code": {
      "type": "integer",
      "description": "业务状态码;成功为 0。",
      "example": 0
    },
    "count": {
      "type": "integer",
      "minimum": 0,
      "description": "符合筛选条件的用户流量套餐总数。",
      "example": 1
    },
    "data": {
      "type": "array",
      "description": "用户流量套餐列表。",
      "items": {
        "type": "object",
        "required": [
          "id",
          "uid",
          "name",
          "traffic_package_id",
          "amount",
          "usage",
          "expire",
          "enable"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "description": "用户流量套餐 ID。",
            "example": 21
          },
          "uid": {
            "type": "integer",
            "description": "归属用户 ID。",
            "example": 12
          },
          "user_name": {
            "type": "string",
            "nullable": true,
            "description": "归属用户名。",
            "example": "demo"
          },
          "name": {
            "type": "string",
            "description": "用户流量套餐名称。",
            "example": "100 GB 加油包"
          },
          "traffic_package_id": {
            "type": "integer",
            "description": "流量套餐定义 ID。",
            "example": 3
          },
          "bind_package": {
            "type": "string",
            "nullable": true,
            "description": "适用的基础套餐定义 ID,以英文逗号分隔;为空表示不限制。",
            "example": "2,3"
          },
          "bind_package_name": {
            "type": "string",
            "nullable": true,
            "description": "适用基础套餐名称的聚合结果。",
            "example": "标准套餐,专业套餐"
          },
          "amount": {
            "type": "string",
            "description": "购买流量总量,单位为 GB、TB 或 PB。",
            "example": "100GB"
          },
          "usage": {
            "type": "integer",
            "minimum": 0,
            "description": "已使用流量。",
            "example": 1073741824
          },
          "price": {
            "type": "number",
            "description": "实际购买价格。",
            "example": 10
          },
          "orgin_price": {
            "type": "number",
            "description": "优惠前购买价格。",
            "example": 12
          },
          "expire": {
            "type": "string",
            "description": "流量套餐到期时间,格式 YYYY-MM-DD HH:mm:ss。",
            "example": "2026-12-31 23:59:59"
          },
          "create_at": {
            "type": "string",
            "description": "创建时间,格式 YYYY-MM-DD HH:mm:ss。",
            "example": "2026-01-01 00:00:00"
          },
          "enable": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "启用状态。",
            "example": 1
          },
          "reason": {
            "type": "string",
            "nullable": true,
            "description": "禁用原因;启用时通常为空。",
            "example": null
          }
        }
      }
    }
  }
}

示例

{
  "code": 0,
  "count": 1,
  "data": [
    {
      "id": 21,
      "uid": 12,
      "user_name": "demo",
      "name": "100 GB 加油包",
      "traffic_package_id": 3,
      "bind_package": "2",
      "bind_package_name": "标准套餐",
      "amount": "100GB",
      "usage": 1073741824,
      "price": 10,
      "orgin_price": 12,
      "expire": "2026-12-31 23:59:59",
      "create_at": "2026-01-01 00:00:00",
      "enable": 1,
      "reason": null
    }
  ]
}

查询成功

{
  "code": 0,
  "count": 1,
  "data": [
    {
      "id": 21,
      "uid": 12,
      "user_name": "demo",
      "name": "100 GB 加油包",
      "traffic_package_id": 3,
      "bind_package": "2",
      "bind_package_name": "标准套餐",
      "amount": "100GB",
      "usage": 1073741824,
      "price": 10,
      "orgin_price": 12,
      "expire": "2026-12-31 23:59:59",
      "create_at": "2026-01-01 00:00:00",
      "enable": 1,
      "reason": null
    }
  ]
}

流量套餐 ID 格式无效

{
  "code": "user_traffic_package-92",
  "msg": "traffic_package_id参数格式不正确",
  "data": ""
}

cURL 示例

根据文档生成;请替换主控地址、路径参数和凭证,并按上表补充查询参数。

curl --request GET \
  "https://master.example.invalid/v1/user-traffic-packages" \
  --header "access-token: YOUR_ACCESS_TOKEN"

查看完整接口 JSON