itecdn 5.x / 用户 API
获取流量套餐详情
GET
/v1/traffic-packages/{package_id}获取单个流量包详情,并按当前登录用户和可选优惠券计算实际售价 new_price。普通用户不能查询已禁用流量包;管理员可查询任意已有流量包。
身份认证
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,必须存在。 完整参数定义 |
coupon_code | query | string | 可选 | 可选。用于计算当前用户购买该流量包后的实际价格;无效或不可用优惠券会返回业务错误。 完整参数定义 |
响应
HTTP 200
请求已被处理。成功时 code 为 0、data 为流量包详情及计算后的 new_price;流量包不存在、普通用户查询禁用项或优惠券不可用时仍返回 HTTP 200。
application/json
object
| 字段 | 类型 | 必填 | 说明与约束 | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
code | integer | 必填 | 业务状态码;成功为 0。 约束 / 默认值 / 示例 | ||||||||||||||||||||||||||||||||||||||||||||||||
msg | string | 必填 | 成功时为空字符串,失败时为错误说明。 约束 / 默认值 / 示例 | ||||||||||||||||||||||||||||||||||||||||||||||||
data | object | 必填 | 流量包详情。 约束 / 默认值 / 示例展开字段结构流量包详情。
|
完整 Schema
{
"type": "object",
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "业务状态码;成功为 0。",
"example": 0
},
"msg": {
"type": "string",
"description": "成功时为空字符串,失败时为错误说明。",
"example": ""
},
"data": {
"type": "object",
"description": "流量包详情。",
"required": [
"id",
"name",
"amount",
"valid_days",
"price",
"new_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",
"description": "可绑定基础套餐 ID 列表。"
},
"valid_days": {
"type": "integer",
"description": "有效天数。"
},
"price": {
"type": "number",
"description": "原始售价。"
},
"new_price": {
"type": "number",
"description": "针对当前用户及 coupon_code 计算后的实际售价。"
},
"enable": {
"type": "integer",
"enum": [
0,
1
],
"description": "启用状态。"
},
"create_at": {
"type": "string",
"description": "创建时间。"
},
"update_at": {
"type": "string",
"nullable": true,
"description": "更新时间。"
}
}
}
}
}示例
{
"code": 0,
"msg": "",
"data": {
"id": 5,
"name": "100GB 流量包",
"des": "月度加油包",
"amount": "100GB",
"bind_package": "1,2",
"valid_days": 30,
"price": 10.5,
"new_price": 9.5,
"enable": 1
}
}查询成功
{
"code": 0,
"msg": "",
"data": {
"id": 5,
"name": "100GB 流量包",
"des": "月度加油包",
"amount": "100GB",
"bind_package": "1,2",
"valid_days": 30,
"price": 10.5,
"new_price": 9.5,
"enable": 1
}
}普通用户查询禁用流量包
{
"code": "traffic_package-26",
"msg": "无权限查询",
"data": ""
}cURL 示例
根据文档生成;请替换主控地址、路径参数和凭证,并按上表补充查询参数。
curl --request GET \
"https://master.example.invalid/v1/traffic-packages/{package_id}" \
--header "access-token: YOUR_ACCESS_TOKEN"