TrailSnap CLI
TIP
TrailSnap CLI is a command-line tool built on TrailSnap APIs. It can be used directly in your terminal, or as a Skill for Agents.
1. Installation
Install trailsnap-cli
You can install trailsnap-cli in one of three ways:
- pip
pip install trailsnap-cli
# Verify installation
trailsnap -v- npm
npm install -g trailsnap-cli
# Verify installation
trailsnap -v- Binary release from GitHub
Download the binary from GitHub Releases and add it to your PATH:
https://github.com/LC044/TrailSnap/releases
Using trailsnap-cli
On first use, configure your API URL and Token (replace <url> and <token> with actual values — see Token Settings):
trailsnap config set --url <url> --token <token>After configuration, verify with a simple query:
trailsnap photos list --limit 52. Command Reference
TIP
All commands are run in the terminal using the format trailsnap <command> <subcommand> [options]. Commands that interact with the API (photos, locations, etc.) require prior configuration via config set, otherwise an error will be shown.
2.1 Basic Commands
2.1.1 help — Show help
Displays all available commands, their structure, and core parameters for quick reference.
trailsnap --help2.2 Configuration Commands
2.2.1 config set — Configure API URL and Token
Configures the CLI with the unified TrailSnap address and Bearer token. This is a prerequisite for all API commands.
Format: config set --url API_URL --token API_TOKEN
Parameters:
--url(required): unified TrailSnap address, e.g.http://localhost:3180. The CLI automatically uses/api.--token(required): API access token (Bearer Token) for authentication, obtained from the backend.
Example:
trailsnap config set --url http://localhost:3180 --token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...On success, the config file path is displayed (written to .env in the same directory).
2.3 Photo Management Commands
2.3.1 photos — Photo management
Contains three sub-commands: list photos, get photo info, and delete a photo. All sub-commands require prior API configuration.
2.3.1.1 photos list — List photos
Query photos with pagination and filtering by album, location, or device info. Returns a simplified field set.
Format: photos list [--skip N] [--limit N] [--album-id ID] [--city CITY] [--province PROVINCE] [--make BRAND] [--model MODEL]
Parameters (can be combined):
--skip: Skip N photos (default 0)--limit: Return N photos (default 10)--order_by: Sort field; defaults to memory score. Options:quality_score,memory_score,photo_time--image-type: Filter by image type, comma-separated. Options:Camera(phone/camera),Screenshot,Other--start-time: Filter by start time, format:YYYY-MM-DD HH:MM:SS--end-time: Filter by end time, format:YYYY-MM-DD HH:MM:SS--album-id: Filter by album ID, comma-separated--people-id: Filter by person ID, comma-separated--tag-id: Filter by tag ID, comma-separated--city: Filter by city, comma-separated (full name)--province: Filter by province, comma-separated (full name)--scene: Filter by scenic spot, comma-separated--make: Filter by camera brand, comma-separated--model: Filter by camera model, comma-separated
Returns: JSON array with id, filename, file_type, photo_time
Example:
trailsnap photos list --limit 20 --city "Xi'an,Shanghai"2.3.1.2 photos info — Get photo details
Get metadata and content description for a specific photo.
Format: photos info --photo-id PHOTO_ID
Parameters:
--photo-id(required): Unique photo ID, obtainable viaphotos list.
Returns: JSON object containing:
address: Detailed shooting address (down to street level)albums: Album informationtags: Tag informationfaces_identities: Person (face identity) informationdescription: Photo content descriptiondescription: Photo scene description (empty string if none)memory_score: Memory worthiness score (0–100, 100 = most memorable)quality_score: Photo quality score (0–100, 100 = highest quality)narrative: One-line caption (empty string if none)
Example:
trailsnap photos info --photo-id 100012.3.1.3 photos delete — Delete a photo
Delete a specific photo by ID. This action is irreversible — use with caution.
Format: photos delete --photo-id PHOTO_ID
Parameters:
--photo-id(required): Unique ID of the photo to delete.
Example:
trailsnap photos delete --photo-id 10001On success: Photo <photo-id> deleted successfully. On failure: Photo deletion failed or not found.
2.4 Tag Commands
2.4.1 tags list — List classification tags
Query classification tags with pagination.
Format: tags list [--skip N] [--limit N]
Parameters:
--skip: Skip N records (default 0)--limit: Return N records (default 100)
Example:
trailsnap tags listReturns: JSON array with id, name (tag_name), count.
2.5 Album Commands
2.5.1 albums list — List albums
Query albums with pagination.
Format: albums list [--skip N] [--limit N]
Parameters:
--skip: Skip N albums (default 0)--limit: Return N albums (default 100)
Returns: JSON array with id, name, count (num_photos), description, condition, type.
Example:
trailsnap albums list2.6 Location Commands
2.6.1 locations — Location queries
Contains two sub-commands: location distribution and footprint timeline, based on photo GPS data.
2.6.1.1 locations list — Query location distribution
Query location distribution without time info (place name, photo count). Supports grouping by level and date range filtering.
Format: locations list [--level city|province|district|scene] [--skip N] [--limit N] [--start-date YYYY-MM-DD] [--end-date YYYY-MM-DD]
Parameters:
--level: Grouping level (defaultcity; options:city,province,district,scene)--skip: Skip N locations (default 0)--limit: Return N locations (default 100)--start-date: Optional start date (YYYY-MM-DD)--end-date: Optional end date (YYYY-MM-DD)
Returns: JSON array with name, count
Example:
trailsnap locations list2.6.1.2 locations timeline — Footprint timeline
Query footprint timeline grouped by time period and location (start date, end date, location name, photo count). Supports grouping by level and date range filtering.
Format: locations timeline [--level city|province|district|scene] [--skip N] [--limit N] [--start-date YYYY-MM-DD] [--end-date YYYY-MM-DD]
Parameters:
--level: Grouping level (defaultcity; options:city,province,district,scene)--skip: Skip N locations (default 0)--limit: Return N locations (default 100)--start-date: Optional start date (YYYY-MM-DD)--end-date: Optional end date (YYYY-MM-DD)
Returns: JSON array with startDate, endDate, locationName, count
Example:
trailsnap locations timeline --level city --start-date 2025-01-01 --end-date 2025-06-302.7 People Commands
2.7.1 people list — List recognized people/faces
Query people (face identities) with type filtering.
Format: people list [--limit N] [--types named,unnamed,hidden]
Parameters:
--limit: Number of records to return (default 100)--types: Query types, comma-separated; defaultnamed. Options:named,unnamed,hidden
Returns: JSON array with id, name (identity_name), tags, description, face_count.
Example:
trailsnap people list2.8 Folder Commands
2.8.1 folders list — List mounted storage folders
Query information about mounted storage directories.
Format: folders list
Returns: JSON output from the backend API (field structure per server response).
Example:
trailsnap folders list2.9 Media Commands
2.9.1 medias get — Get photo media file or URL
Get media content/access URL for a specific photo, supporting URL, base64, or local file output.
Format: medias get [--photo-id ID] [--size small|medium|large] [--format url|base64|file] [--output FILE_PATH]
Parameters:
--photo-id: Photo ID (default 100)--size: Photo quality/size (defaultmedium; options:small,medium,large)--format: Output format (defaulturl— can be embedded in HTML/Markdown; options:url,base64,file)--output: Output file path (required only when--format file)
Example:
# Output URL (large = original image URL; small/medium = thumbnail URL)
trailsnap medias get --photo-id 10001 --format url --size large
# Base64 output (thumbnail base64 encoding)
trailsnap medias get --photo-id 10001 --format base64 --size medium
# Save to local file
trailsnap medias get --photo-id 10001 --format file --output ./photo_10001.jpg2.10 Notes
- All API-interacting commands (photos, locations, people, etc.) require prior
config setwith API URL and Token. Otherwise, the error messageError: API URL and Token not configured. Please run 'config' first.will be shown. - All commands support
--helpfor detailed usage. Invalid parameters will show specific error messages and the correct format.