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

获取网站详情

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

要查询的网站 ID,必须是当前用户的网站;管理员可查询任意已有网站。

完整参数定义
{
  "name": "site_id",
  "in": "path",
  "required": true,
  "schema": {
    "type": "integer"
  },
  "description": "要查询的网站 ID,必须是当前用户的网站;管理员可查询任意已有网站。"
}

响应

HTTP 200

请求已被处理。成功时 code 为 0,data 为网站详情;网站不存在或无权限时仍返回 HTTP 200 并提供业务错误码。

application/json

object

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

业务状态码;成功为 0。

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

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

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

网站详情。JSON 配置字段以字符串形式返回。

约束 / 默认值 / 示例
{
  "required": [
    "id",
    "uid",
    "domain",
    "backend",
    "user_package",
    "enable",
    "site_state"
  ]
}
展开字段结构

网站详情。JSON 配置字段以字符串形式返回。

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

网站 ID。

uidinteger必填

网站归属用户 ID。

namestring可选

归属用户名。

domainstring必填

网站域名,多个域名以空白字符分隔。

backendstring必填

源站列表的 JSON 字符串;每项包含 addr、weight、state。

backend_hoststring可选

回源 Host 配置。

backend_protocolstring可选

回源协议:follow、http 或 https。

backend_http_portinteger可选

HTTP 回源端口。

backend_https_portinteger可选

HTTPS 回源端口。

backend_port_mappinginteger可选

是否启用回源端口映射。

balance_waystring可选

负载均衡方式。

http_listenstring可选

HTTP 监听配置的 JSON 字符串。

https_listenstring可选

HTTPS 监听配置的 JSON 字符串。

user_packageinteger必填

使用的用户套餐 ID。

package_idinteger可选

底层套餐 ID。

package_namestring可选

用户套餐名称。

end_atstring可选

用户套餐到期时间,格式为 YYYY-MM-DD HH:mm:ss。

约束 / 默认值 / 示例
{
  "nullable": true
}
region_idinteger可选

区域 ID。

region_namestring可选

区域名称。

node_group_idinteger可选

主线路组 ID。

node_group_namestring可选

主线路组名称。

node_group_ipv6integer可选

主线路组是否含 IPv6 节点。

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

备用线路组 ID。

约束 / 默认值 / 示例
{
  "nullable": true
}
backup_node_group_namestring可选

备用线路组名称。

约束 / 默认值 / 示例
{
  "nullable": true
}
cname_modestring可选

CNAME 使用方式。

cname_hostnamestring可选

网站 CNAME 主机名。

cname_domainstring可选

网站 CNAME 域名。

约束 / 默认值 / 示例
{
  "nullable": true
}
up_cname_domainstring可选

套餐 CNAME 域名。

约束 / 默认值 / 示例
{
  "nullable": true
}
up_cname_hostnamestring可选

套餐 CNAME 主机名。

约束 / 默认值 / 示例
{
  "nullable": true
}
enableinteger必填

网站是否启用。

约束 / 默认值 / 示例
{
  "enum": [
    0,
    1
  ]
}
site_statestring必填

网站当前状态。

sync_statestring可选

网站同步任务状态。

约束 / 默认值 / 示例
{
  "nullable": true
}
cname_statestring可选

CNAME 任务状态。

约束 / 默认值 / 示例
{
  "nullable": true
}
task_idinteger可选

网站同步任务 ID。

约束 / 默认值 / 示例
{
  "nullable": true
}
cname_task_idinteger可选

CNAME 任务 ID。

约束 / 默认值 / 示例
{
  "nullable": true
}
groupsstring可选

网站分组 ID 的逗号分隔字符串。

约束 / 默认值 / 示例
{
  "nullable": true
}
group_namestring可选

网站分组名称的逗号分隔字符串。

约束 / 默认值 / 示例
{
  "nullable": true
}
health_checkstring可选

健康检查配置的 JSON 字符串。

proxy_timeoutinteger可选

回源读取超时秒数。

proxy_connect_timeoutinteger可选

回源连接超时秒数。

proxy_authstring可选

回源认证配置的 JSON 字符串。

proxy_cacheinteger可选

是否启用代理缓存。

proxy_http_versionstring可选

回源 HTTP 版本。

proxy_ssl_protocolsstring可选

回源 TLS 协议配置。

gzip_enableinteger可选

是否启用 Gzip。

gzip_typesstring可选

Gzip MIME 类型。

websocket_enableinteger可选

是否启用 WebSocket。

corsstring可选

跨域配置的 JSON 字符串。

hotlinkstring可选

防盗链配置的 JSON 字符串。

aclstring可选

访问控制列表配置。

约束 / 默认值 / 示例
{
  "nullable": true
}
black_ipstring可选

IP 黑名单配置。

white_ipstring可选

IP 白名单配置。

block_proxyinteger可选

是否拦截代理请求。

block_regionstring可选

地域拦截配置。

cc_default_rulestring可选

默认 CC 防护规则 ID。

cc_switchstring可选

CC 开关配置的 JSON 字符串。

condition_backendstring可选

条件回源配置的 JSON 字符串。

extra_cc_rulestring可选

附加 CC 规则配置。

req_headerstring可选

请求头改写配置。

resp_headerstring可选

响应头改写配置。

url_rewritestring可选

URL 重写配置。

page_403string可选

403 页面配置。

page_404string可选

404 页面配置。

page_500string可选

500 页面配置。

page_502string可选

502 页面配置。

page_504string可选

504 页面配置。

create_at2string可选

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

update_at2string可选

更新时间,格式为 YYYY-MM-DD HH:mm:ss。

versioninteger可选

配置版本号。

完整 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"

查看完整接口 JSON