88API88API
使用指南AI 應用API 文件幫助支援

站點配置模組

功能說明

介面字首統一為 http(s)://<your-domain>

生產環境應使用 HTTPS 以保證認證令牌。 HTTP 僅建議用於開發環境。

最高許可權的系統配置管理,僅 Root 使用者可訪問 。包含全域性引數配置、模型倍率重置、控制檯設定遷移等功能。配置更新包含嚴格的依賴驗證邏輯。

🔐 Root鑑權

獲取全域性配置

  • 介面名稱:獲取全域性配置
  • HTTP 方法:GET
  • 路徑/api/option/
  • 鑑權要求:Root
  • 功能簡介:獲取系統所有全域性配置選項,過濾敏感資訊如 Token、Secret、Key 等 💡 請求示例:
const response = await fetch('/api/option/', {
  method: 'GET',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer your_root_token',
    'New-Api-User': 'your_user_id'
  }
});
const data = await response.json();

✅ 成功響應示例:

{
  "success": true,
  "message": "",
  "data": [
    {
      "key": "SystemName",
      "value": "88API"
    },
    {
      "key": "DisplayInCurrencyEnabled",
      "value": "true"
    },
    {
      "key": "QuotaPerUnit",
      "value": "500000"
    }
  ]
}

❗ 失敗響應示例:

{
  "success": false,
  "message": "獲取配置失敗"
}

🧾 欄位說明:

data (陣列): 配置項列表 option.go:15-18

  • key (字串): 配置項鍵名
  • value (字串): 配置項值,敏感資訊已過濾 option.go:22-24

更新全域性配置

  • 介面名稱:更新全域性配置
  • HTTP 方法:PUT
  • 路徑/api/option/
  • 鑑權要求:Root
  • 功能簡介:更新單個全域性配置項,包含配置驗證和依賴檢查

💡 請求示例:

const response = await fetch('/api/option/', {
  method: 'PUT',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer your_root_token',
    'New-Api-User': 'your_user_id'
  },
  body: JSON.stringify({
    key: "SystemName",
    value: "My 88API System"
  })
});
const data = await response.json();

✅ 成功響應示例:

{
  "success": true,
  "message": "配置更新成功"
}

❗ 失敗響應示例:

{
  "success": false,
  "message": "無法啟用 GitHub OAuth,請先填入 GitHub Client Id 以及 GitHub Client Secret!"
}

🧾 欄位說明:

  • key (字串): 配置項鍵名,必填 option.go:39-42
  • value (任意型別): 配置項值,支援布林型、數字、字串等型別 option.go:54-63

重置模型倍率

  • 介面名稱:重置模型倍率
  • HTTP 方法:POST
  • 路徑/api/option/rest_model_ratio
  • 鑑權要求:Root
  • 功能簡介:重置所有模型的倍率配置到預設值,用於批次重置模型定價

💡 請求示例:

const response = await fetch('/api/option/rest_model_ratio', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer your_root_token',
    'New-Api-User': 'your_user_id'
  }
});
const data = await response.json();

✅ 成功響應示例:

{
  "success": true,
  "message": "模型倍率重置成功"
}

❗ 失敗響應示例:

{
  "success": false,
  "message": "重置模型倍率失敗"
}

🧾 欄位說明:

無請求引數,執行後會重置所有模型倍率配置

遷移舊版控制檯配置

  • 介面名稱:遷移舊版控制檯配置
  • HTTP 方法:POST
  • 路徑/api/option/migrate_console_setting
  • 鑑權要求:Root
  • 功能簡介:將舊版本的控制檯配置遷移到新的配置格式,包括 API 資訊、公告、FAQ 等

💡 請求示例:

const response = await fetch('/api/option/migrate_console_setting', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer your_root_token',
    'New-Api-User': 'your_user_id'
  }
});
const data = await response.json();

✅ 成功響應示例:

{
  "success": true,
  "message": "migrated"
}

❗ 失敗響應示例:

{
  "success": false,
  "message": "遷移失敗"
}

🧾 欄位說明:

  • 無請求引數
  • 遷移內容包括:
    • ApiInfoconsole_setting.api_info
    • Announcementsconsole_setting.announcements
    • FAQconsole_setting.faq
    • UptimeKumaUrl/UptimeKumaSlugconsole_setting.uptime_kuma_groups