获取网站详情
/v1/sites/{site_id}获取指定网站的完整配置、套餐、线路和任务状态。普通用户只能读取自己的网站;读取其他用户的网站需要管理员权限。配置类字段按数据库原值返回,其中多项为 JSON 字符串,调用方需要自行解析。
身份认证
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 同时发送。"
}
}请求参数
| 参数 | 位置 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|---|
site_id | path | integer | 必填 | 要查询的网站 ID,必须是当前用户的网站;管理员可查询任意已有网站。 完整参数定义 |
响应
HTTP 200
请求已被处理。成功时 code 为 0,data 为网站详情;网站不存在或无权限时仍返回 HTTP 200 并提供业务错误码。
application/json
object
| 字段 | 类型 | 必填 | 说明与约束 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
code | integer | 必填 | 业务状态码;成功为 0。 约束 / 默认值 / 示例 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
msg | string | 必填 | 成功时为空字符串,失败时为错误说明。 约束 / 默认值 / 示例 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
data | object | 必填 | 网站详情。JSON 配置字段以字符串形式返回。 约束 / 默认值 / 示例展开字段结构网站详情。JSON 配置字段以字符串形式返回。
|
完整 Schema
{
"type": "object",
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "业务状态码;成功为 0。",
"example": 0
},
"msg": {
"type": "string",
"description": "成功时为空字符串,失败时为错误说明。",
"example": ""
},
"data": {
"type": "object",
"description": "网站详情。JSON 配置字段以字符串形式返回。",
"required": [
"id",
"uid",
"domain",
"backend",
"user_package",
"enable",
"site_state"
],
"properties": {
"id": {
"type": "integer",
"description": "网站 ID。"
},
"uid": {
"type": "integer",
"description": "网站归属用户 ID。"
},
"name": {
"type": "string",
"description": "归属用户名。"
},
"domain": {
"type": "string",
"description": "网站域名,多个域名以空白字符分隔。"
},
"backend": {
"type": "string",
"description": "源站列表的 JSON 字符串;每项包含 addr、weight、state。"
},
"backend_host": {
"type": "string",
"description": "回源 Host 配置。"
},
"backend_protocol": {
"type": "string",
"description": "回源协议:follow、http 或 https。"
},
"backend_http_port": {
"type": "integer",
"description": "HTTP 回源端口。"
},
"backend_https_port": {
"type": "integer",
"description": "HTTPS 回源端口。"
},
"backend_port_mapping": {
"type": "integer",
"description": "是否启用回源端口映射。"
},
"balance_way": {
"type": "string",
"description": "负载均衡方式。"
},
"http_listen": {
"type": "string",
"description": "HTTP 监听配置的 JSON 字符串。"
},
"https_listen": {
"type": "string",
"description": "HTTPS 监听配置的 JSON 字符串。"
},
"user_package": {
"type": "integer",
"description": "使用的用户套餐 ID。"
},
"package_id": {
"type": "integer",
"description": "底层套餐 ID。"
},
"package_name": {
"type": "string",
"description": "用户套餐名称。"
},
"end_at": {
"type": "string",
"nullable": true,
"description": "用户套餐到期时间,格式为 YYYY-MM-DD HH:mm:ss。"
},
"region_id": {
"type": "integer",
"description": "区域 ID。"
},
"region_name": {
"type": "string",
"description": "区域名称。"
},
"node_group_id": {
"type": "integer",
"description": "主线路组 ID。"
},
"node_group_name": {
"type": "string",
"description": "主线路组名称。"
},
"node_group_ipv6": {
"type": "integer",
"enum": [
0,
1
],
"description": "主线路组是否含 IPv6 节点。"
},
"backup_node_group": {
"type": "integer",
"nullable": true,
"description": "备用线路组 ID。"
},
"backup_node_group_name": {
"type": "string",
"nullable": true,
"description": "备用线路组名称。"
},
"cname_mode": {
"type": "string",
"description": "CNAME 使用方式。"
},
"cname_hostname": {
"type": "string",
"description": "网站 CNAME 主机名。"
},
"cname_domain": {
"type": "string",
"nullable": true,
"description": "网站 CNAME 域名。"
},
"up_cname_domain": {
"type": "string",
"nullable": true,
"description": "套餐 CNAME 域名。"
},
"up_cname_hostname": {
"type": "string",
"nullable": true,
"description": "套餐 CNAME 主机名。"
},
"enable": {
"type": "integer",
"enum": [
0,
1
],
"description": "网站是否启用。"
},
"site_state": {
"type": "string",
"description": "网站当前状态。"
},
"sync_state": {
"type": "string",
"nullable": true,
"description": "网站同步任务状态。"
},
"cname_state": {
"type": "string",
"nullable": true,
"description": "CNAME 任务状态。"
},
"task_id": {
"type": "integer",
"nullable": true,
"description": "网站同步任务 ID。"
},
"cname_task_id": {
"type": "integer",
"nullable": true,
"description": "CNAME 任务 ID。"
},
"groups": {
"type": "string",
"nullable": true,
"description": "网站分组 ID 的逗号分隔字符串。"
},
"group_name": {
"type": "string",
"nullable": true,
"description": "网站分组名称的逗号分隔字符串。"
},
"health_check": {
"type": "string",
"description": "健康检查配置的 JSON 字符串。"
},
"proxy_timeout": {
"type": "integer",
"description": "回源读取超时秒数。"
},
"proxy_connect_timeout": {
"type": "integer",
"description": "回源连接超时秒数。"
},
"proxy_auth": {
"type": "string",
"description": "回源认证配置的 JSON 字符串。"
},
"proxy_cache": {
"type": "integer",
"description": "是否启用代理缓存。"
},
"proxy_http_version": {
"type": "string",
"description": "回源 HTTP 版本。"
},
"proxy_ssl_protocols": {
"type": "string",
"description": "回源 TLS 协议配置。"
},
"gzip_enable": {
"type": "integer",
"description": "是否启用 Gzip。"
},
"gzip_types": {
"type": "string",
"description": "Gzip MIME 类型。"
},
"websocket_enable": {
"type": "integer",
"description": "是否启用 WebSocket。"
},
"cors": {
"type": "string",
"description": "跨域配置的 JSON 字符串。"
},
"hotlink": {
"type": "string",
"description": "防盗链配置的 JSON 字符串。"
},
"acl": {
"type": "string",
"nullable": true,
"description": "访问控制列表配置。"
},
"black_ip": {
"type": "string",
"description": "IP 黑名单配置。"
},
"white_ip": {
"type": "string",
"description": "IP 白名单配置。"
},
"block_proxy": {
"type": "integer",
"description": "是否拦截代理请求。"
},
"block_region": {
"type": "string",
"description": "地域拦截配置。"
},
"cc_default_rule": {
"type": "string",
"description": "默认 CC 防护规则 ID。"
},
"cc_switch": {
"type": "string",
"description": "CC 开关配置的 JSON 字符串。"
},
"condition_backend": {
"type": "string",
"description": "条件回源配置的 JSON 字符串。"
},
"extra_cc_rule": {
"type": "string",
"description": "附加 CC 规则配置。"
},
"req_header": {
"type": "string",
"description": "请求头改写配置。"
},
"resp_header": {
"type": "string",
"description": "响应头改写配置。"
},
"url_rewrite": {
"type": "string",
"description": "URL 重写配置。"
},
"page_403": {
"type": "string",
"description": "403 页面配置。"
},
"page_404": {
"type": "string",
"description": "404 页面配置。"
},
"page_500": {
"type": "string",
"description": "500 页面配置。"
},
"page_502": {
"type": "string",
"description": "502 页面配置。"
},
"page_504": {
"type": "string",
"description": "504 页面配置。"
},
"create_at2": {
"type": "string",
"description": "创建时间,格式为 YYYY-MM-DD HH:mm:ss。"
},
"update_at2": {
"type": "string",
"description": "更新时间,格式为 YYYY-MM-DD HH:mm:ss。"
},
"version": {
"type": "integer",
"description": "配置版本号。"
}
}
}
}
}示例
{
"code": 0,
"msg": "",
"data": {
"id": 101,
"uid": 12,
"domain": "www.example.invalid",
"backend": "[{\"addr\": \"198.51.100.10\", \"weight\": 1, \"state\": \"up\"}]",
"user_package": 8,
"enable": 1,
"site_state": "done"
}
}查询成功
{
"code": 0,
"msg": "",
"data": {
"id": 101,
"uid": 12,
"domain": "www.example.invalid",
"backend": "[{\"addr\": \"198.51.100.10\", \"weight\": 1, \"state\": \"up\"}]",
"user_package": 8,
"enable": 1,
"site_state": "done"
}
}网站不存在
{
"code": "site-127",
"msg": "网站不存在",
"data": ""
}cURL 示例
根据文档生成;请替换主控地址、路径参数和凭证,并按上表补充查询参数。
curl --request GET \
"https://master.example.invalid/v1/sites/{site_id}" \
--header "access-token: YOUR_ACCESS_TOKEN"