← Back to index

document_type: "api_reference" service: "MOMENTRY_CORE" title: "Momentry Core API 快速查詢表" date: "2026-05-17" version: "V1.1" status: "active" owner: "M5" created_by: "OpenCode"


Momentry Core API 快速查詢表

Base URL

Environment URL Purpose
Playground (Dev) http://localhost:3003 Development and testing
Production http://localhost:3002 Production deployment
External (M5) https://m5api.momentry.ddns.net Remote access

Variables

API="http://localhost:3003"
KEY="your-api-key-here"

Authentication

Mode Transport Expiry Scope Best for
Session Cookie Cookie: session_id=<uuid> 24h per-browser session Portal (browser)
JWT Authorization: Bearer <token> 1h per-login token API clients (n8n, CLI, scripts)
API Key X-API-Key: <key> 90d fixed key for automation Legacy scripts, WordPress
Username Password API Key Role
admin admin — admin
demo demo muser_demo_key_32chars_abcdef1234567890 user
# Using API key instead of JWT
curl -s "$API/api/v1/files/scan" -H "X-API-Key: muser_demo_key_32chars_abcdef1234567890"
# Login as admin
curl -s -X POST "$API/api/v1/auth/login" \
  -H "Content-Type: application/json" \
  -d '{"username": "admin", "password": "admin"}'

# Login as demo user
curl -s -X POST "$API/api/v1/auth/login" \
  -H "Content-Type: application/json" \
  -d '{"username": "demo", "password": "demo"}'
Field Type Description
jwt string JWT access token. Use as Authorization: Bearer <jwt>. Expires in 1 hour.
api_key string Legacy API key. Use as X-API-Key: <key>. Good for 90 days.
user.username string Username
user.role string Role: admin, user, or readonly
expires_at string ISO8601 timestamp of JWT expiration
# Login and capture JWT
JWT=$(curl -s -X POST "$API/api/v1/auth/login" \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"admin"}' | python3 -c "import json,sys;print(json.load(sys.stdin)['jwt'])")

# Use JWT for all subsequent requests
curl -H "Authorization: Bearer $JWT" "$API/api/v1/files/scan"
curl -H "Authorization: Bearer $JWT" "$API/api/v1/resource/tmdb"
# Login captures the session cookie from Set-Cookie header
curl -v -X POST "$API/api/v1/auth/login" \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"admin"}' 2>&1 | grep "Set-Cookie"

# Browser automatically sends: Cookie: session_id=<uuid>
# No manual header needed for subsequent requests
curl -H "X-API-Key: $KEY" "$API/api/v1/files/scan"

# Also accepted via Bearer header (non-JWT format) or query parameter:
curl -H "Authorization: Bearer $KEY" "$API/api/v1/files/scan"
curl "$API/api/v1/files/scan?api_key=$KEY"
momentry api-key create "My API Key" --key-type user
# Logout using the session cookie (browser)
curl -X POST "$API/api/v1/auth/logout" \
  -H "Cookie: session_id=<uuid>"
Auth mode Effect
Session Cookie Session deleted from database. Same cookie returns 401 on subsequent requests.
JWT JWT remains valid until expiry. (JWT is stateless — logout adds JWT to a blacklist only if API key mode is used.)
API Key API key remains valid. (Legacy keys are shared across sessions — revoking would break other clients.)
# 1. Login
SESSION_ID=$(curl -s -D - -X POST "$API/api/v1/auth/login" \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"admin"}' | grep "Set-Cookie" | sed 's/.*session_id=\([^;]*\).*/\1/')

# 2. Use session (works)
curl -s -o /dev/null -w "HTTP %{http_code}\n" "$API/api/v1/resource/tmdb" \
  -H "Cookie: session_id=$SESSION_ID"
# → HTTP 200

# 3. Logout
curl -s -X POST "$API/api/v1/auth/logout" \
  -H "Cookie: session_id=$SESSION_ID"
# → {"success": true}

# 4. Use session again (rejected)
curl -s -o /dev/null -w "HTTP %{http_code}\n" "$API/api/v1/resource/tmdb" \
  -H "Cookie: session_id=$SESSION_ID"
# → HTTP 401

Error Responses

HTTP When
401 Missing or invalid authentication
401 Session expired or logged out
401 JWT expired
401 API key revoked or inactive


Health Check

curl "$API/health" | jq '{status, version}'
Field Type Description
status string ok or degraded
version string Semver version
build_git_hash string Git commit hash
build_timestamp string Binary build time
uptime_ms integer Milliseconds since server start
curl "$API/health/detailed" | jq '{status, services, resources: {cpu: .resources.cpu_used_percent, memory: .resources.memory_used_percent}}'
Field Type Description
status string ok if all essential services healthy
services object Per-service status (postgres, redis, qdrant)
services.*.status string ok, error, or degraded
services.*.latency_ms int Response time in milliseconds
resources object CPU, memory usage
pipeline.scripts_ready boolean Scripts directory accessible
pipeline.scripts_count int Number of Python processor scripts
pipeline.processors object Per-processor availability
pipeline.models_ready boolean Models directory accessible
pipeline.scripts_integrity object SHA256 checksum verification results
schema.ok boolean All required migrations applied
identities.synced boolean Identity file count matches DB count
integrations.tmdb object TMDB API key config and reachability
Condition status
All services ok ok
Any service error degraded
Postgres or Redis error degraded (server still responds)
Method Endpoint Auth Description
GET /api/v1/stats/ingest No Ingest pipeline statistics
GET /api/v1/stats/sftpgo No SFTPGo service status
GET /api/v1/stats/inference No Inference service (LLM) health
curl "$API/api/v1/stats/ingest"

File Registration

Field Type Required Default Description
file_path string Yes — Path to video file on disk
pattern string No — Regex pattern for batch register (requires file_path to be a directory)
user_id integer No — User ID to associate with registration
content_hash string No — Pre-computed SHA-256 hash (skips computation)
# Register a single file
curl -s -X POST "$API/api/v1/files/register" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $KEY" \
  -d '{"file_path": "/path/to/video.mp4"}'

# Batch register files matching a pattern in a directory
curl -s -X POST "$API/api/v1/files/register" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $KEY" \
  -d '{"file_path": "/path/to/dir", "pattern": ".*\\.mp4$"}'
Field Type Description
success boolean Always true on 200
file_uuid string 32-char hex UUID of the registered file
file_name string File name (auto-renamed if name conflict)
file_path string Canonical path on disk
file_type string "video", "audio", or "unknown"
duration float Duration in seconds
width integer Video width in pixels
height integer Video height in pixels
fps float Frames per second
total_frames integer Total frame count
already_exists boolean True if same content was already registered
message string Human-readable status
HTTP When
401 Missing or invalid API key
400 Invalid request body
404 File path does not exist
Field Type Required Default Description
page integer No 1 Page number (1-based)
page_size integer No all Items per page (alias: limit)
limit integer No all Max items (alias for page_size)
pattern string No — Regex filter on file name (e.g., .*\\.mp4$)
sort_by string No name Sort field: name, size, modified, status
sort_order string No asc Sort direction: asc or desc
# Full scan
curl -s "$API/api/v1/files/scan" -H "X-API-Key: $KEY" | jq '{total, registered_count, unregistered_count}'

# Paginated (page 1, 5 per page)
curl -s "$API/api/v1/files/scan?page=1&page_size=5" -H "X-API-Key: $KEY" | jq '{page, total_pages, files: [.files[].file_name]}'

# Regex filter: only mp4 files
curl -s "$API/api/v1/files/scan?pattern=.*\\.mp4$" -H "X-API-Key: $KEY" | jq '{filtered_total, files: [.files[].file_name]}'

# Sort by file size (largest first)
curl -s "$API/api/v1/files/scan?sort_by=size&sort_order=desc&page_size=5" -H "X-API-Key: $KEY" | jq '[.files[] | {file_name, file_size}]'

# Sort by modified time (most recent first)
curl -s "$API/api/v1/files/scan?sort_by=modified&sort_order=desc&page_size=5" -H "X-API-Key: $KEY" | jq '[.files[] | {file_name, modified_time}]'

# Sort by status
curl -s "$API/api/v1/files/scan?sort_by=status&page_size=5" -H "X-API-Key: $KEY" | jq '[.files[] | {file_name, status}]'
Field Type Description
files array Array of file info objects (paginated)
files[].file_name string File name
files[].relative_path string Path relative to scan root
files[].file_path string Absolute path on disk
files[].file_size integer File size in bytes
files[].modified_time string Last modified timestamp (ISO8601)
files[].is_registered boolean Whether file is registered in DB
files[].file_uuid string 32-char hex UUID (only if registered)
files[].status string "completed", "processing", "registered", "unregistered", or null
files[].registration_time string DB registration timestamp (only if registered)
files[].job_id integer Processing job ID (only if a job exists)
total integer Total files found on disk (unfiltered)
filtered_total integer Files matching regex filter
page integer Current page number
page_size integer Items per page
total_pages integer Total pages
registered_count integer Files registered in DB
unregistered_count integer Files not yet registered
Feature Behavior
Regex Case-insensitive ((?i) prefix auto-applied). Applied to file_name.
Sort order Default (sort_by=name): registered files first, then alphabetically. sort_by=status: alphabetical by status string.
Pagination page_size and limit are aliases. Default: show all results.
Processing order pattern regex filter → sort_by/sort_order → page/page_size slice.

File Lookup

Field Type Required Description
file_name string Yes File name to search for (partial matches supported)
# Look up a specific file
curl -s "$API/api/v1/files/lookup?file_name=video.mp4" \
  -H "X-API-Key: $KEY"

# Partial name search
curl -s "$API/api/v1/files/lookup?file_name=charade" \
  -H "X-API-Key: $KEY" | jq '.matches[].file_name'
Field Type Description
file_name string Searched name
exists boolean Exact name match exists
matches array Array of matching registered files
matches[].file_uuid string 32-char hex UUID
matches[].file_name string Registered file name
matches[].file_type string "video", "audio", or null
matches[].status string Registration/processing status
next_name string Suggested name for avoiding conflicts

Unregister

Removed (default) Not removed
Database records (videos, chunks, embeddings, processor_results, pre_chunks) The original source video file on disk
Processor output JSON files ({uuid}.*.json) — unless delete_output_files: false Temp/working directories
In-memory cache entries
MongoDB cached lists
Field Type Required Default Description
file_uuid string * — Single file UUID to delete
file_path string * — Directory path (for batch delete)
pattern string * — Regex pattern (requires file_path)
delete_output_files boolean No true If true, also delete processor output JSON files ({uuid}.*.json). Set to false to keep them.
# Delete a single file by UUID (default: also deletes output JSON files)
curl -s -X POST "$API/api/v1/unregister" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $KEY" \
  -d '{"file_uuid": "'"$FILE_UUID"'"}'

# Keep output JSON files, only delete DB records
curl -s -X POST "$API/api/v1/unregister" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $KEY" \
  -d '{"file_uuid": "'"$FILE_UUID"'", "delete_output_files": false}'

# Batch delete all mp4 files in a directory
curl -s -X POST "$API/api/v1/unregister" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $KEY" \
  -d '{"file_path": "/path/to/dir", "pattern": ".*\\.mp4$"}'
Field Type Description
success boolean True if deletion succeeded
file_uuid string UUID of the deleted file (single mode)
message string Human-readable status
HTTP When
400 Neither file_uuid nor file_path+pattern provided
404 File UUID not found
401 Missing or invalid API key

Processing Pipeline

Field Type Required Default Description
processors string[] No all Specific processors to run: ["asr","cut","yolo","ocr","face","pose","asrx","visual_chunk"]
rules string[] No all Rule names to apply (currently unused)
# Run all processors
curl -s -X POST "$API/api/v1/file/$FILE_UUID/process" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $KEY" -d '{}'

# Run specific processors only
curl -s -X POST "$API/api/v1/file/$FILE_UUID/process" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $KEY" \
  -d '{"processors": ["asr", "face", "yolo"]}'
Field Type Description
success boolean Always true on 200
job_id integer Monitor job ID (for job tracking)
file_uuid string 32-char hex UUID of the file
status string "processing"
pids integer[] Process IDs of started processors
message string Human-readable status
HTTP When
404 File UUID not found
401 Missing or invalid API key
curl -s "$API/api/v1/file/$FILE_UUID/probe" -H "X-API-Key: $KEY"
Field Type Description
file_uuid string 32-char hex UUID
file_name string File name
file_size integer File size in bytes (from filesystem)
duration float Duration in seconds
width integer Video width in pixels
height integer Video height in pixels
fps float Frames per second
total_frames integer Estimated total frames
cached boolean True if result was from cached probe JSON
format object Container format info (ffprobe format section)
streams array Array of stream info objects
curl -s "$API/api/v1/progress/$FILE_UUID" -H "X-API-Key: $KEY" | jq '{overall_progress, processors: [.processors[] | {processor_type, status}]}'
Field Type Description
file_uuid string 32-char hex UUID
overall_progress integer Overall progress percentage (0–100)
processors array Per-processor status list
processors[].processor_type string Processor name (asr, cut, yolo, etc.)
processors[].status string "pending", "running", "complete", or "failed"
processors[].progress integer Per-processor progress (0–100)
cpu_percent float Current CPU usage
gpu_percent float Current GPU utilization
memory_percent float Current memory usage
curl -s "$API/api/v1/jobs" -H "X-API-Key: $KEY" | jq '{count, jobs: [.jobs[] | {uuid, status}]}'
Field Type Description
jobs array Array of job info objects
jobs[].id integer Job ID
jobs[].uuid string File UUID being processed
jobs[].status string "pending", "running", "completed", "failed"
jobs[].current_processor string Currently active processor, or null
count integer Total job count
page integer Current page number
page_size integer Jobs per page

Search APIs

Field Type Required Default Description
query string Yes — Search text
file_uuid string No — Restrict search to a specific file
limit integer No 10 Max results
page integer No 1 Page number (1-based)
page_size integer No limit Items per page (alias: page_size)
mode string No smart Search mode: "vector" or "smart"
# Search across all files
curl -s -X POST "$API/api/v1/search" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $KEY" \
  -d '{"query": "charade", "limit": 5}'

# Search within a specific file
curl -s -X POST "$API/api/v1/search" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $KEY" \
  -d '{"query": "charade", "file_uuid": "'"$FILE_UUID"'"}'

# Paginated search
curl -s -X POST "$API/api/v1/search" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $KEY" \
  -d '{"query": "charade", "page": 1, "page_size": 3}'
Field Type Description
results array Array of matched chunks (deduplicated)
results[].uuid string File UUID
results[].chunk_id string Chunk identifier
results[].chunk_type string "sentence", "cut", "trace", "visual"
results[].start_time float Start time in seconds
results[].end_time float End time in seconds
results[].text string Chunk text content
results[].score float Similarity score (0.0–1.0)
query string Original search query
total integer Total matching results
page integer Current page number
page_size integer Items per page
HTTP When
401 Missing or invalid API key
Field Type Required Default Description
query string Yes — Search text
file_uuid string No — Restrict search to a specific file
limit integer No 10 Max results
page integer No 1 Page number (1-based)
page_size integer No limit Items per page
vector_weight float No 0.5 Weight for vector score (0.0–1.0)
bm25_weight float No 0.5 Weight for BM25 score (0.0–1.0)
Field Type Description
results[].vector_score float Vector similarity score
results[].bm25_score float BM25 text score
results[].combined_score float Weighted combination of both scores
Method Endpoint Description
POST /api/v1/n8n/search N8N-format vector search
POST /api/v1/n8n/search/bm25 N8N-format BM25 search
POST /api/v1/n8n/search/hybrid N8N-format hybrid search
POST /api/v1/n8n/search/smart N8N-format smart search
Field Type Required Default Description
query string Yes — Search text
file_uuid string No — Restrict to specific file
types string[] No ["chunk"] Search types: chunk, frame, person
filters object No — Filter criteria (confidence, object class, speaker, etc.)
page integer No 1 Page number
page_size integer No 20 Items per page
time_range float[2] No — Time range [start, end] in seconds
curl -s -X POST "$API/api/v1/n8n/search" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $KEY" \
  -d '{"query": "charade", "limit": 5}'
Field Type Description
results array Array of search results
results[].type string Result type: "chunk", "frame", or "person"
results[].chunk_id string Chunk identifier
results[].chunk_type string Chunk type
results[].file_uuid string File UUID
results[].start_time float Start time in seconds
results[].end_time float End time in seconds
results[].text string Content text
results[].score float Relevance score
total integer Total matching results
page integer Current page
page_size integer Items per page
took_ms integer Query execution time in milliseconds
Field Type Required Description
file_uuid string Yes File UUID to search within
q string Yes Text search query
limit integer No Max results (default 50)
page integer No 1
page_size integer No limit
curl -s "$API/api/v1/search/identity_text?file_uuid=$FILE_UUID&q=charade&page=1&page_size=5" \
  -H "X-API-Key: $KEY"
Field Type Description
file_uuid string File UUID
chunk_id string Chunk identifier
start_time float Start time in seconds
end_time float End time in seconds
text_content string Chunk text content
identity_id integer Identity ID (null if no identity matched)
identity_name string Identity name (null if no identity matched)
identity_source string Identity origin. .json = established from identity.json files on disk (unified format for all sources). tmdb = from .json via TMDb enrichment probe, then matched against faces. auto = pipeline face matching result; only stranger identities are auto-created. user_defined = manual. merged = merged identities.
trace_id integer Face trace ID (null if no trace matched)
Field Type Required Description
q string Yes Identity name search
file_uuid string No Restrict to specific file
limit integer No Max results (default 50)
curl -s -X POST "$API/api/v1/identities/search" \
  -H "X-API-Key: $KEY" \
  -d '{"q": "Cary Grant"}'
Method Endpoint Description
POST /api/v1/search/visual Search visual chunks by criteria (object classes, density)
POST /api/v1/search/visual/class Search by specific object class
POST /api/v1/search/visual/density Search by spatial density range
POST /api/v1/search/visual/stats Get visual detection statistics
POST /api/v1/search/visual/combination Search by object class combination
Field Type Required Description
file_uuid string Yes File UUID
criteria.required_classes string[] No Required object classes (e.g., ["person", "car"])
criteria.min_confidence float No Minimum confidence threshold
criteria.min_spatial_density float No Minimum spatial density
criteria.max_spatial_density float No Maximum spatial density
curl -s -X POST "$API/api/v1/search/visual" \
  -H "X-API-Key: $KEY" \
  -H "Content-Type: application/json" \
  -d '{"file_uuid": "'"$FILE_UUID"'", "criteria": {"required_classes": ["person", "car"]}}'
Field Type Description
chunks array Array of matching visual chunks
chunks[].file_uuid string File UUID
chunks[].chunk_id string Chunk identifier
chunks[].detections array Object detections in this chunk
total integer Total matching chunks

TMDb Enrichment

Field Type Required Description
file_uuid string Yes File UUID to enrich
curl -s -X POST "$API/api/v1/agents/tmdb/prefetch" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $KEY" \
  -d '{"file_uuid": "'"$FILE_UUID"'"}'
curl -s -X POST "$API/api/v1/file/$FILE_UUID/tmdb-probe" \
  -H "X-API-Key: $KEY" | jq '{identities_created, movie_title}'
curl -s "$API/api/v1/resource/tmdb" -H "X-API-Key: $KEY" \
  | jq '{identities_seeded, cache_files}'
curl -s -X POST "$API/api/v1/resource/tmdb/check" \
  -H "X-API-Key: $KEY" | jq '.status'

POST /api/v1/agents/translate

Field Type Required Description
text string ✅ Text to translate
target_language string ✅ Target language name (e.g. "Traditional Chinese", "Japanese")
source_language string ❌ Source language (default: "auto")

Response

```json | Source | Target | Quality | |--------|--------|---------| | English | Traditional Chinese | ✅ | | English | Japanese | ✅ | | Chinese | English | ✅ | | English | French | ✅ | | Chinese | Japanese | ✅ |

Errors

Status Condition
500 LLM unreachable or response parse failure
401 Missing/invalid auth

GET /api/v1/agents/identity/status

Get status of the identity agent pipeline.

Response

```json

POST /api/v1/agents/suggest/clustering

POST /api/v1/agents/suggest/merge

POST /api/v1/agents/5w1h/analyze

Response

```json

POST /api/v1/agents/5w1h/batch

GET /api/v1/agents/5w1h/status