88API88API
使用指南AI 應用API 文件幫助支援
介面模組使用指南

日誌模組

功能說明

介面前綴統一為 https://88api.ai

呼叫日誌查詢介面,可檢視目前帳號的呼叫日誌,提供實時統計(RPM/TPM)和多維度過濾等功能。支援 CORS 的 Token 查詢介面便於第三方整合。

🔐 無需鑑權

根據 Token 查詢日誌

  • 介面名稱:根據 Token 查詢日誌
  • HTTP 方法:GET
  • 路徑:/api/log/token
  • 鑑權要求:公開
  • 功能簡介:透過 Token 金鑰查詢相關日誌記錄,支援跨域訪問

💡 請求示例:

const response = await fetch('/api/log/token?key=`<TOKEN_PLACEHOLDER>`', {
  method: 'GET',
  headers: {
    'Content-Type': 'application/json'
  }
});
const data = await response.json();

✅ 成功響應示例:

{
  "success": true,
  "message": "",
  "data": [
    {
      "id": 1,
      "type": 2,
      "content": "API呼叫成功",
      "model_name": "gpt-5.5",
      "quota": 1000,
      "created_at": 1640995000
    }
  ]
}

❗ 失敗響應示例:

{
  "success": false,
  "message": "Token不存在或無許可權"
}

🧾 欄位說明:

key (字串): Token 金鑰,必填

🔐 使用者鑑權

我的日誌統計

  • 介面名稱:我的日誌統計
  • HTTP 方法:GET
  • 路徑:/api/log/self/stat
  • 鑑權要求:使用者
  • 功能簡介:獲取當前使用者的日誌統計資訊,包括配額消耗、請求頻率和 Token 使用量

💡 請求示例:

const response = await fetch('/api/log/self/stat?type=2&start_timestamp=1640908800&end_timestamp=1640995200&token_name=api_token&model_name=gpt-5.5&group=default', {
  method: 'GET',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer your_user_token',
    'New-Api-User': 'your_user_id'
  }
});
const data = await response.json();

✅ 成功響應示例:

{
  "success": true,
  "message": "",
  "data": {
    "quota": 50000,
    "rpm": 10,
    "tpm": 1500
  }
}

❗ 失敗響應示例:

{
  "success": false,
  "message": "獲取統計資訊失敗"
}

🧾 欄位說明:

  • type (數字): 日誌型別,可選值:1=充值,2=消費,3=管理,4=錯誤,5=系統
  • start_timestamp (數字): 開始時間戳
  • end_timestamp (數字): 結束時間戳
  • token_name (字串): Token 名稱過濾
  • model_name (字串): 模型名稱過濾
  • group (字串): 分組過濾
  • quota (數字): 指定時間範圍內的總配額消耗
  • rpm (數字): 每分鐘請求數(最近 60 秒)
  • tpm (數字): 每分鐘 Token 數(最近 60 秒)

獲取我的日誌

  • 介面名稱:獲取我的日誌
  • HTTP 方法:GET
  • 路徑:/api/log/self
  • 鑑權要求:使用者
  • 功能簡介:分頁獲取當前使用者的日誌記錄,支援多種過濾條件

💡 請求示例:

const response = await fetch('/api/log/self?p=1&page_size=20&type=2&start_timestamp=1640908800&end_timestamp=1640995200&token_name=api_token&model_name=gpt-5.5&group=default', {
  method: 'GET',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer your_user_token',
    'New-Api-User': 'your_user_id'
  }
});
const data = await response.json();

✅ 成功響應示例:

{
  "success": true,
  "message": "",
  "data": {
    "items": [
      {
        "id": 1,
        "user_id": 1,
        "created_at": 1640995000,
        "type": 2,
        "content": "API呼叫成功",
        "token_name": "api_token",
        "model_name": "gpt-5.5",
        "quota": 1000,
        "prompt_tokens": 50,
        "completion_tokens": 100
      }
    ],
    "total": 25,
    "page": 1,
    "page_size": 20
  }
}

❗ 失敗響應示例:

{
  "success": false,
  "message": "獲取日誌失敗"
}

🧾 欄位說明:

  • p (數字): 頁碼,預設為 1
  • page_size (數字): 每頁數量,預設為 20
  • type (數字): 日誌型別,可選值:1=充值,2=消費,3=管理,4=錯誤,5=系統
  • start_timestamp (數字): 開始時間戳
  • end_timestamp (數字): 結束時間戳
  • token_name (字串): Token 名稱過濾
  • model_name (字串): 模型名稱過濾
  • group (字串): 分組過濾

只返回當前使用者的日誌記錄。

搜尋我的日誌

  • 介面名稱:搜尋我的日誌
  • HTTP 方法:GET
  • 路徑:/api/log/self/search
  • 鑑權要求:使用者
  • 功能簡介:根據關鍵詞搜尋當前使用者的日誌記錄

💡 請求示例:

const response = await fetch('/api/log/self/search?keyword=gpt-5.5', {
  method: 'GET',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer your_user_token',
    'New-Api-User': 'your_user_id'
  }
});
const data = await response.json();

✅ 成功響應示例:

{
  "success": true,
  "message": "",
  "data": [
    {
      "id": 1,
      "type": 2,
      "content": "API呼叫成功",
      "model_name": "gpt-5.5",
      "created_at": 1640995000
    }
  ]
}

❗ 失敗響應示例:

{
  "success": false,
  "message": "搜尋日誌失敗"
}

🧾 欄位說明:

keyword (字串): 搜尋關鍵詞,匹配當前使用者的日誌型別