CAFORADocs
开发者

服务器 Client API

服务器 Client API:当前界面的操作步骤与使用说明。

当前接口入口

当前游戏面板使用 Pterodactyl Client API,基础地址是 https://panel.caforahost.com/api/client。旧文档的 api.caforahost.com/v1 不是本次核对到的公开接口,请勿照旧示例调用。

方法与路径用途
GET /api/client列出账号可访问的服务器
GET /api/client/servers/{identifier}服务器信息
GET /api/client/servers/{identifier}/resources当前运行状态与资源
POST /api/client/servers/{identifier}/power电源操作,JSON 字段 signal
POST /api/client/servers/{identifier}/command控制台命令,JSON 字段 command

使用 Panel 创建的 Client API Key,并按权限发送 Authorization: Bearer ... 和 Accept: application/json。不要公开密钥或把客户 API 密钥放在前端代码中。路径中的标识符来自自己的服务器,不是商店订单号。

curl --fail-with-body \
  -H "Authorization: Bearer ${PANEL_API_KEY}" \
  -H "Accept: application/json" \
  "https://panel.caforahost.com/api/client/servers/${SERVER_IDENTIFIER}/resources"

运行前在自己的环境设置变量。资源响应的 attributes.current_state 表示状态;资源统计不包含可靠的在线玩家列表。写操作有真实副作用,先在自己的测试服务验证。

本页内容