# Momentry Studio Core API 使用說明 本文檔整理 Momentry Studio 使用的 Core API 端點及其使用時機。 **Core API 地址**: `http://localhost:3002` **API Key**: 透過 `api_key` query parameter 注入(由 Rust proxy 自動處理) --- ## 一、搜尋相關 API ### 1.1 智能搜尋 | 端點 | 方法 | 說明 | |------|------|------| | `/api/v1/search/llm-smart` | POST | LLM 智能搜尋,結合關鍵字和語意搜尋 | | `/api/v1/search/keyword` | POST | 純關鍵字搜尋 | | `/api/v1/search/semantic` | POST | 純語意搜尋(向量相似度) | | `/api/v1/agents/search` | POST | Agent 搜尋(支援多輪對話) | **使用時機**: - `llm-smart`: 搜尋頁面預設搜尋 - `keyword`: 快速關鍵字匹配 - `semantic`: 概念搜尋 - `agents/search`: 搜尋頁面對話模式(支援 `conversation_id` 多輪對話) **Request Body**: ```json { "query": "搜尋詞", "limit": 20 } ``` **Response**: 搜尋結果陣列,每個結果包含 `file_uuid`, `start_time`, `end_time`, `start_frame`, `end_frame`, `summary`, `similarity` --- ### 1.2 人物搜尋 | 端點 | 方法 | 說明 | |------|------|------| | `/api/v1/identities/search` | GET | 搜尋人物名稱 | **使用時機**: 在人物詳情頁面搜尋要合併的目標人物 **Query Params**: `q` (搜尋詞), `limit` --- ## 二、檔案管理 API ### 2.1 檔案列表與詳情 | 端點 | 方法 | 說明 | |------|------|------| | `/api/v1/files/scan` | GET | 掃描目錄,取得檔案列表 | | `/api/v1/file/:uuid` | GET | 取得檔案詳情(fps, duration, width, height 等) | | `/api/v1/file/:uuid/processor-counts` | GET | 取得檔案的處理器計數統計 | **使用時機**: - `files/scan`: 檔案庫頁面載入檔案列表 - `file/:uuid`: 播放器需要影片參數、縮圖需要原始尺寸 - `processor-counts`: 檔案詳情頁面顯示處理狀態 --- ### 2.2 檔案註冊與處理 | 端點 | 方法 | 說明 | |------|------|------| | `/api/v1/files/register` | POST | 註冊檔案到系統 | | `/api/v1/file/:uuid/process` | POST | 執行處理器(transcribe, ocr, face 等) | | `/api/v1/file/:uuid/checkin` | POST | 檔案入庫(ingest) | | `/api/v1/file/:uuid/checkout` | POST | 檔案出庫 | | `/api/v1/unregister` | POST | 取消註冊檔案 | **使用時機**: - `register`: 檔案庫頁面註冊新檔案 - `process`: 檔案庫頁面觸發處理流程 - `checkin/checkout`: 檔案版本控制 - `unregister`: 檔案庫頁面刪除檔案 --- ### 2.3 檔案狀態同步 | 端點 | 方法 | 說明 | |------|------|------| | `/api/v1/file/:uuid/sync-status` | POST | 從資料庫同步檔案處理狀態 | **使用時機**: 前端 polling 檢查處理中的檔案狀態(每 10 秒) --- ## 三、媒體 API ### 3.1 縮圖 | 端點 | 方法 | 說明 | 實作位置 | |------|------|------|----------| | `/api/v1/file/:uuid/thumbnail` | GET | 取得檔案縮圖 | Core API | | `/api/v1/face-thumbnail` | GET | 取得人臉縮圖(含 bbox crop) | **Studio 本地** | | `/api/v1/file/thumbnail` | GET | 依路徑取得縮圖(未註冊檔案) | **Studio 本地** | **使用時機**: - `file/:uuid/thumbnail`: 搜尋結果縮圖、影片時間軸縮圖 - `face-thumbnail`: 人物詳情頁面人臉縮圖(含 bbox crop) - `file/thumbnail`: 檔案庫頁面未註冊檔案的縮圖 **注意**: `face-thumbnail` 由 Studio 本地處理,因為 Core API 不支援 bbox crop --- ### 3.2 影片串流 | 端點 | 方法 | 說明 | |------|------|------| | `/api/v1/file/:uuid/video` | GET | 影片串流 | **使用時機**: 搜尋結果播放影片 **注意**: Core API 已支援 HTTP Range requests,瀏覽器可透過 `