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

Midjourney 任務模組

功能說明

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

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

影象生成任務的管理系統 。支援任務狀態跟蹤、進度監控、結果檢視等功能。包含圖片 URL 轉發和後臺輪詢更新機制。

🔐 使用者鑑權

獲取自己的 MJ 任務

  • 介面名稱:獲取自己的 MJ 任務
  • HTTP 方法:GET
  • 路徑/api/mj/self
  • 鑑權要求:使用者
  • 功能簡介:分頁獲取當前使用者的 Midjourney 任務列表,支援按任務 ID 和時間範圍過濾

💡 請求示例:

const response = await fetch('/api/mj/self?p=1&page_size=20&mj_id=task123&start_timestamp=1640908800&end_timestamp=1640995200', {
  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,
        "mj_id": "task123456",
        "action": "IMAGINE",
        "prompt": "a beautiful landscape",
        "prompt_en": "a beautiful landscape",
        "status": "SUCCESS",
        "progress": "100%",
        "image_url": "https://example.com/image.jpg",
        "video_url": "https://example.com/video.mp4",
        "video_urls": "[\"https://example.com/video1.mp4\"]",
        "submit_time": 1640908800,
        "start_time": 1640909000,
        "finish_time": 1640909200,
        "fail_reason": "",
        "quota": 1000
      }
    ],
    "total": 25,
    "page": 1,
    "page_size": 20
  }
}

❗ 失敗響應示例:

{
  "success": false,
  "message": "獲取任務列表失敗"
}

🧾 欄位說明:

  • p (數字): 頁碼,預設為 1
  • page_size (數字): 每頁數量,預設為 20
  • mj_id (字串): 任務 ID 過濾,可選
  • start_timestamp (數字): 開始時間戳,可選
  • end_timestamp (數字): 結束時間戳,可選
  • 返回欄位說明:
    • id (數字): 資料庫記錄 ID
    • mj_id (字串): Midjourney 任務唯一識別符號
    • action (字串): 操作型別,如 IMAGINE、UPSCALE 等
    • prompt (字串): 原始提示詞
    • prompt_en (字串): 英文提示詞
    • status (字串): 任務狀態 midjourney.go:19
    • progress (字串): 完成進度百分比
    • image_url (字串): 生成的圖片 URL
    • video_url (字串): 生成的影片 URL
    • video_urls (字串): 多個影片 URL 的 JSON 陣列字串
    • submit_time (數字): 提交時間戳
    • start_time (數字): 開始處理時間戳
    • finish_time (數字): 完成時間戳
    • fail_reason (字串): 失敗原因
    • quota (數字): 消耗的配額

🔐 管理員鑑權

獲取全部 MJ 任務

  • 介面名稱:獲取全部 MJ 任務
  • HTTP 方法:GET
  • 路徑/api/mj/
  • 鑑權要求:管理員
  • 功能簡介:分頁獲取系統中所有 Midjourney 任務,支援按渠道 ID、任務 ID 和時間範圍過濾

💡 請求示例:

const response = await fetch('/api/mj/?p=1&page_size=20&channel_id=1&mj_id=task123&start_timestamp=1640908800&end_timestamp=1640995200', {
  method: 'GET',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer your_admin_token',
    'New-Api-User': 'your_user_id'
  }
});
const data = await response.json();

✅ 成功響應示例:

{
  "success": true,
  "message": "",
  "data": {
    "items": [
      {
        "id": 1,
        "user_id": 1,
        "mj_id": "task123456",
        "action": "IMAGINE",
        "prompt": "a beautiful landscape",
        "status": "SUCCESS",
        "progress": "100%",
        "image_url": "https://example.com/image.jpg",
        "channel_id": 1,
        "quota": 1000,
        "submit_time": 1640908800,
        "finish_time": 1640909200
      }
    ],
    "total": 100,
    "page": 1,
    "page_size": 20
  }
}

❗ 失敗響應示例:

{
  "success": false,
  "message": "獲取任務列表失敗"
}

🧾 欄位說明:

  • p (數字): 頁碼,預設為 1
  • page_size (數字): 每頁數量,預設為 20
  • channel_id (字串): 渠道 ID 過濾,可選
  • mj_id (字串): 任務 ID 過濾,可選
  • start_timestamp (字串): 開始時間戳,可選
  • end_timestamp (字串): 結束時間戳,可選
  • 返回欄位包含使用者自身任務的所有欄位,另外增加:
    • user_id (數字): 任務所屬使用者 ID
    • channel_id (數字): 使用的渠道 ID