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

获取用户套餐详情

GET/v1/user-packages/{package_id}

获取用户套餐详情。可选传入 duration 试算续费价格,或传入 to_package 试算更换至另一基础套餐的差价;可同时传入优惠码参与续费价格计算。普通用户只能查看自己的套餐,管理员可查看任意套餐。

身份认证

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_idpathinteger必填

要查询的用户套餐 ID,必须存在且当前用户有权限查看。

完整参数定义
{
  "name": "package_id",
  "in": "path",
  "required": true,
  "schema": {
    "type": "integer",
    "minimum": 1,
    "example": 8
  },
  "description": "要查询的用户套餐 ID,必须存在且当前用户有权限查看。"
}
durationquerystring可选

可选。传入后返回该期限的续费及已购升级包价格试算。

完整参数定义
{
  "name": "duration",
  "in": "query",
  "required": false,
  "schema": {
    "type": "string",
    "enum": [
      "month",
      "quarter",
      "year"
    ],
    "example": "month"
  },
  "description": "可选。传入后返回该期限的续费及已购升级包价格试算。"
}
coupon_codequerystring可选

可选。续费试算时使用的优惠码;不可用时返回业务错误。

完整参数定义
{
  "name": "coupon_code",
  "in": "query",
  "required": false,
  "schema": {
    "type": "string",
    "example": "WELCOME10"
  },
  "description": "可选。续费试算时使用的优惠码;不可用时返回业务错误。"
}
to_packagequeryinteger可选

可选。目标基础套餐 ID;传入后返回更换套餐的周期、当前价格、新套餐价格与差价试算。

完整参数定义
{
  "name": "to_package",
  "in": "query",
  "required": false,
  "schema": {
    "type": "integer",
    "minimum": 1,
    "example": 3
  },
  "description": "可选。目标基础套餐 ID;传入后返回更换套餐的周期、当前价格、新套餐价格与差价试算。"
}

响应

HTTP 200

请求已被处理。成功时 data 为用户套餐详情,并按请求可选附加续费或换套餐试算字段;套餐不存在、无权限或优惠码不可用时仍返回 HTTP 200。

application/json

object

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

业务状态码;成功为 0。

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

成功时为空字符串,失败时为错误说明。

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

用户套餐详情与可选价格试算结果。

约束 / 默认值 / 示例
{
  "required": [
    "id",
    "uid",
    "package",
    "name",
    "start_at2",
    "end_at2",
    "traffic_reset_time"
  ]
}
展开字段结构

用户套餐详情与可选价格试算结果。

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

用户套餐 ID。

uidinteger必填

归属用户 ID。

packageinteger必填

基础套餐定义 ID。

package_namestring可选

基础套餐名称。

namestring必填

用户套餐名称。

start_at2string必填

生效时间。

end_at2string必填

到期时间。

traffic_reset_timestring必填

下一次流量重置时间。

traffic_usageinteger可选

已使用流量。

trafficinteger可选

流量额度,-1 表示不限。

enableinteger可选

启用状态。

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

禁用原因。

cname_hostnamestring可选

套餐 CNAME 主机名。

basic_pricenumber可选

续费试算中的基础套餐价格,仅传 duration 时返回。

up_pricenumber可选

续费试算中的升级包价格,仅传 duration 时返回。

total_pricenumber可选

续费试算总价,仅传 duration 时返回。

orgin_pricenumber可选

续费试算原价,仅传 duration 时返回。

periodstring可选

换套餐试算的当前计费周期,仅传 to_package 时返回。

curr_pricenumber可选

换套餐试算的当前套餐价格。

new_pricenumber可选

换套餐试算的新套餐价格。

diff_pricenumber可选

换套餐试算的应补或应退差价。

remain_daysinteger可选

换套餐试算使用的剩余天数。

完整 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",
        "uid",
        "package",
        "name",
        "start_at2",
        "end_at2",
        "traffic_reset_time"
      ],
      "properties": {
        "id": {
          "type": "integer",
          "description": "用户套餐 ID。"
        },
        "uid": {
          "type": "integer",
          "description": "归属用户 ID。"
        },
        "package": {
          "type": "integer",
          "description": "基础套餐定义 ID。"
        },
        "package_name": {
          "type": "string",
          "description": "基础套餐名称。"
        },
        "name": {
          "type": "string",
          "description": "用户套餐名称。"
        },
        "start_at2": {
          "type": "string",
          "description": "生效时间。"
        },
        "end_at2": {
          "type": "string",
          "description": "到期时间。"
        },
        "traffic_reset_time": {
          "type": "string",
          "description": "下一次流量重置时间。"
        },
        "traffic_usage": {
          "type": "integer",
          "description": "已使用流量。"
        },
        "traffic": {
          "type": "integer",
          "description": "流量额度,-1 表示不限。"
        },
        "enable": {
          "type": "integer",
          "enum": [
            0,
            1
          ],
          "description": "启用状态。"
        },
        "reason": {
          "type": "string",
          "description": "禁用原因。"
        },
        "cname_hostname": {
          "type": "string",
          "description": "套餐 CNAME 主机名。"
        },
        "basic_price": {
          "type": "number",
          "description": "续费试算中的基础套餐价格,仅传 duration 时返回。"
        },
        "up_price": {
          "type": "number",
          "description": "续费试算中的升级包价格,仅传 duration 时返回。"
        },
        "total_price": {
          "type": "number",
          "description": "续费试算总价,仅传 duration 时返回。"
        },
        "orgin_price": {
          "type": "number",
          "description": "续费试算原价,仅传 duration 时返回。"
        },
        "period": {
          "type": "string",
          "description": "换套餐试算的当前计费周期,仅传 to_package 时返回。"
        },
        "curr_price": {
          "type": "number",
          "description": "换套餐试算的当前套餐价格。"
        },
        "new_price": {
          "type": "number",
          "description": "换套餐试算的新套餐价格。"
        },
        "diff_price": {
          "type": "number",
          "description": "换套餐试算的应补或应退差价。"
        },
        "remain_days": {
          "type": "integer",
          "description": "换套餐试算使用的剩余天数。"
        }
      }
    }
  }
}

示例

{
  "code": 0,
  "msg": "",
  "data": {
    "id": 8,
    "uid": 12,
    "package": 2,
    "package_name": "标准套餐",
    "name": "我的标准套餐",
    "start_at2": "2026-01-01 00:00:00",
    "end_at2": "2026-02-01 00:00:00",
    "traffic_reset_time": "2026-02-01 00:00:00",
    "traffic_usage": 1073741824,
    "traffic": 100,
    "enable": 1
  }
}

套餐详情

{
  "code": 0,
  "msg": "",
  "data": {
    "id": 8,
    "uid": 12,
    "package": 2,
    "package_name": "标准套餐",
    "name": "我的标准套餐",
    "start_at2": "2026-01-01 00:00:00",
    "end_at2": "2026-02-01 00:00:00",
    "traffic_reset_time": "2026-02-01 00:00:00",
    "traffic_usage": 1073741824,
    "traffic": 100,
    "enable": 1
  }
}

套餐不存在

{
  "code": "user_package-15",
  "msg": "用户套餐不存在",
  "data": ""
}

cURL 示例

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

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

查看完整接口 JSON