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 表示狀態;資源統計不包含可靠的線上玩家列表。寫操作有真實副作用,先在自己的測試服務驗證。

本頁內容