访问接口 API 文档
适用范围
- 该访问接口用于账户内实例的创建、续费、变更,以及按实例管理应用。
- 实例与应用分别创建。独立面板通过独立面板列表查询,每项带有应用编码 app_id,其 url 可用于 iframe 内嵌。
- 应用是否开启见应用的 is_opened。独立面板是否启用见独立面板列表中的 is_opened。
通用部分
- 接口统一使用 POST 请求,使用 x-www-form-urlencoded 类型传输字段。
- 每个请求均携带 access_id 与 access_key 参数,即接口编码与接口秘钥。调用前该密钥须已开启。密钥是否有效,以该次请求的返回为准;查询账户资金即可确认。
- 返回结果以 JSON 返回:如果成功,则返回 data 字段,包含具体结果,类型以具体请求而定;如果出错,则返回 error 字段,包含具体错误,类型为文本。
- 请求均以 curl 为例说明。域名使用 v4.yingyongdun.com,替换参数即可直接测试。
- 下面返回示例里的 /* 说明 */ 只用于阅读,真实响应是不带注释的 JSON。
出错示例
{
"error": "AccessID 无效"
}
查询账户资金
请求
curl --location 'https://v4.yingyongdun.com/api/v1/user/fund' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'access_id=接口编码' \
--data-urlencode 'access_key=接口秘钥'
返回
{
"data": {
"balance": "192.00", /* 余额 */
"profit": "0.00" /* 收益(来源于推广活动等) */
}
}
查询账户下所有实例
请求
curl --location 'https://v4.yingyongdun.com/api/v1/user/instances' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'access_id=接口编码' \
--data-urlencode 'access_key=接口秘钥'
返回
{
"data": [
{
"id": 100002, /* 编码 */
"label": "防护实例", /* 名称 */
"is_disabled": false, /* 是否被禁用 */
"is_paused": false, /* 是否被暂停(包括到期或手动暂停) */
"client": 200, /* 客户端同时在线数配额 */
"bandwidth": 20, /* 带宽配额 */
"target": 5, /* 源机数配额 */
"create_time": 1692515895, /* 创建时间(时间戳) */
"plan": { /* 套餐,调试实例为 null */
"plan_id": 2002, /* 套餐编码 */
"remain": 32789404, /* 剩余时间(单位:秒) */
"expire_time": 1760944778 /* 到期日期(时间戳) */
}
} /* 注意是数组包含多条记录 */
]
}
获取套餐计划列表
请求
curl --location 'https://v4.yingyongdun.com/api/v1/user/plans' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'access_id=接口编码' \
--data-urlencode 'access_key=接口秘钥'
返回
{
"data": [
{
"id": 2002, /* 编码 */
"group": "个人", /* 分组 */
"label": "特惠版", /* 名称 */
"client": 200, /* 客户端同时在线数配额 */
"target": 5, /* 源机数配额 */
"price": "399.00" /* 每月价格 */
} /* 注意是数组包含多条记录 */
]
}
计算实例新购价格
请求
curl --location 'https://v4.yingyongdun.com/api/v1/user/instance/plan/create-calc' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'access_id=接口编码' \
--data-urlencode 'access_key=接口秘钥' \
--data-urlencode 'plan_id=套餐编码' \
--data-urlencode 'month=月数'
返回
{
"data": {
"price": "399.00", /* 价格 */
"save": "0.00", /* 已减(通常因年付或促销减去的金额) */
"is_disabled": false, /* 是否不能购买(比如旧套餐或业务冲突) */
"tip": "" /* 系统提示(比如无法购买的原因) */
}
}
实例新购
新购的实例名称为「防护实例」。新购前须完成实名认证。
请求
curl --location 'https://v4.yingyongdun.com/api/v1/user/instance/create' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'access_id=接口编码' \
--data-urlencode 'access_key=接口秘钥' \
--data-urlencode 'plan_id=套餐编码' \
--data-urlencode 'month=月数'
返回
{
"data": {
"instance_id": 10002 /* 编号 */
}
}
计算实例变更价格
请求
curl --location 'https://v4.yingyongdun.com/api/v1/user/instance/plan/modify-calc' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'access_id=接口编码' \
--data-urlencode 'access_key=接口秘钥' \
--data-urlencode 'instance_id=实例编码' \
--data-urlencode 'plan_id=需变更到的套餐编码'
返回
{
"data": {
"price": "399.00", /* 补充费用(降级不退费,且需临近到期才可操作) */
"is_disabled": false, /* 是否不能购买(比如旧套餐或业务冲突) */
"tip": "" /* 系统提示(比如无法升级的原因) */
}
}
当前配置时 price 为 "0.00",is_disabled 为 true,tip 为「当前配置」。降级且距离到期超过允许天数时,is_disabled 为 true,tip 说明仅支持到期前若干天内操作。
实例变更
请求
curl --location 'https://v4.yingyongdun.com/api/v1/user/instance/plan/modify' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'access_id=接口编码' \
--data-urlencode 'access_key=接口秘钥' \
--data-urlencode 'instance_id=实例编码' \
--data-urlencode 'plan_id=需变更到的套餐编码'
返回
{
"data": null /* 无返回结果 */
}
计算实例续期价格
请求
curl --location 'https://v4.yingyongdun.com/api/v1/user/instance/plan/renew-calc' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'access_id=接口编码' \
--data-urlencode 'access_key=接口秘钥' \
--data-urlencode 'instance_id=实例编码' \
--data-urlencode 'month=月数'
返回
{
"data": {
"price": "399.00", /* 价格 */
"save": "0.00", /* 已减(通常因年付或促销减去的金额) */
"is_disabled": false, /* 是否不能续期(比如旧套餐或业务冲突) */
"tip": "" /* 系统提示(比如无法续期的原因) */
}
}
实例续期
请求
curl --location 'https://v4.yingyongdun.com/api/v1/user/instance/renew' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'access_id=接口编码' \
--data-urlencode 'access_key=接口秘钥' \
--data-urlencode 'instance_id=实例编码' \
--data-urlencode 'month=月数'
返回
{
"data": null /* 无返回结果 */
}
列举实例下的应用
按实例返回应用列表。is_opened 表示应用是否开启。offset 默认 0,limit 默认 100,最大 100。
请求
curl --location 'https://v4.yingyongdun.com/api/v1/user/app/list' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'access_id=接口编码' \
--data-urlencode 'access_key=接口秘钥' \
--data-urlencode 'instance_id=实例编码' \
--data-urlencode 'offset=0' \
--data-urlencode 'limit=100'
返回
{
"data": {
"items": [
{
"app_id": 3001, /* 应用编码 */
"label": "我的应用", /* 名称 */
"is_opened": true, /* 应用是否开启 */
"client": 200, /* 客户端同时在线数上限 */
"target": 5, /* 源机数上限 */
"bandwidth": 20, /* 带宽 */
"expire_time": 0, /* 到期时间,0 表示不启用到期 */
"create_time": 1692515895 /* 创建时间(时间戳) */
} /* 注意是数组包含多条记录 */
],
"total": 1, /* 总数 */
"limit": 100 /* 本次条数上限 */
}
}
创建应用
名称 label 长度为 1 至 32 位,可在同一实例下重复创建。is_opened、client、target、expire_time 可选,只写入本次提交的字段。
请求
curl --location 'https://v4.yingyongdun.com/api/v1/user/app/create' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'access_id=接口编码' \
--data-urlencode 'access_key=接口秘钥' \
--data-urlencode 'instance_id=实例编码' \
--data-urlencode 'label=名称' \
--data-urlencode 'is_opened=1' \
--data-urlencode 'client=200' \
--data-urlencode 'target=5' \
--data-urlencode 'expire_time=0'
返回
{
"data": {
"app_id": 3001 /* 应用编码 */
}
}
删除应用
删除应用时,该应用的独立面板记录会一并去掉。
请求
curl --location 'https://v4.yingyongdun.com/api/v1/user/app/delete' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'access_id=接口编码' \
--data-urlencode 'access_key=接口秘钥' \
--data-urlencode 'instance_id=实例编码' \
--data-urlencode 'app_id=应用编码'
返回
{
"data": null /* 无返回结果 */
}
修改应用
可修改 is_opened(应用开关)、label(名称)、client 与 target(上限)、expire_time(到期时间)。这些字段均为可选,只修改本次提交的字段,未提交的保持原值。其它参数返回「参数错误」。
请求
curl --location 'https://v4.yingyongdun.com/api/v1/user/app/update' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'access_id=接口编码' \
--data-urlencode 'access_key=接口秘钥' \
--data-urlencode 'instance_id=实例编码' \
--data-urlencode 'app_id=应用编码' \
--data-urlencode 'label=名称' \
--data-urlencode 'is_opened=1' \
--data-urlencode 'client=200' \
--data-urlencode 'target=5' \
--data-urlencode 'expire_time=0'
返回
{
"data": null /* 无返回结果 */
}
列举独立面板
按实例返回独立面板。offset 默认 0,limit 默认 100,最大 100。返回 items、total、limit。
请求
curl --location 'https://v4.yingyongdun.com/api/v1/user/external/list' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'access_id=接口编码' \
--data-urlencode 'access_key=接口秘钥' \
--data-urlencode 'instance_id=实例编码' \
--data-urlencode 'offset=0' \
--data-urlencode 'limit=100'
返回
{
"data": {
"items": [
{
"app_id": 3001, /* 应用编码 */
"is_opened": true, /* 是否启用面板 */
"uuid": "fac199ca", /* 独立面板编码 */
"url": "..." /* 独立面板访问网址,域名为实际分配的面板域名 */
} /* 注意是数组包含多条记录 */
],
"total": 1, /* 总数 */
"limit": 100 /* 本次条数上限 */
}
}
打开独立面板
为指定应用打开独立面板。打开后请再列举独立面板,读取 uuid 与 url。
请求
curl --location 'https://v4.yingyongdun.com/api/v1/user/instance/external/open' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'access_id=接口编码' \
--data-urlencode 'access_key=接口秘钥' \
--data-urlencode 'instance_id=实例编码' \
--data-urlencode 'app_id=应用编码'
返回
{
"data": null /* 无返回结果 */
}
关闭独立面板
关闭指定应用的独立面板。uuid 与访问网址保持不变。
请求
curl --location 'https://v4.yingyongdun.com/api/v1/user/instance/external/close' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'access_id=接口编码' \
--data-urlencode 'access_key=接口秘钥' \
--data-urlencode 'instance_id=实例编码' \
--data-urlencode 'app_id=应用编码'
返回
{
"data": null /* 无返回结果 */
}