Search Content
Search for specific moments inside your videos using natural language queries.
Basic Search
Section titled “Basic Search”Search across all your videos:
import { createClient } from "zapdos-js";
const client = createClient({ apiKey: process.env.ZAPDOS_API_KEY,});
const searchResults = await client.search("person walking in the park");
if (searchResults.data) { searchResults.data.items.forEach((scene) => { console.log(`Found in video: ${scene.metadata.object_id}`); console.log( `Time: ${scene.metadata.start_ms}ms - ${scene.metadata.end_ms}ms` ); console.log(`Confidence: ${scene.score}`); });}
Search with Filters
Section titled “Search with Filters”Limit search to specific videos:
// Search within specific videosconst filteredSearch = await client.search("action scene", { limit: 10, object_ids: ["video-id-1", "video-id-2"],});
// Search within a single videoconst singleVideoSearch = await client.search("explosion", { video_id: "specific-video-id", limit: 5,});
Search Options
Section titled “Search Options”Configure your search with options:
const searchResults = await client.search("query text", { limit: 20, // Max results (default varies) object_ids: ["id1", "id2"], // Search specific videos only video_id: "single-video-id", // Search single video only});
Understanding Results
Section titled “Understanding Results”Each search result contains detailed metadata:
const results = await client.search("car driving");
if (results.data) { results.data.items.forEach((scene) => { console.log({ id: scene.id, type: scene.type, // "scene" score: scene.score, // Confidence Score videoId: scene.metadata.object_id, // Source video videoName: scene.metadata.object_original_name, startTime: scene.metadata.start_ms, // Scene start (ms) endTime: scene.metadata.end_ms, // Scene end (ms) sceneIndex: scene.metadata.scene_index, // Scene number thumbnailId: scene.metadata.scene_image_object_id, }); });}
Error Handling
Section titled “Error Handling”Handle search errors gracefully:
const results = await client.search("my query");
if (results.error) { console.error("Search failed:", results.error.message);} else if (results.data.items.length === 0) { console.log("No results found");} else { console.log(`Found ${results.data.items.length} scenes`);}
Best Practices
Section titled “Best Practices”- Use descriptive, natural language queries
- Start with broader terms, then refine with filters
- Higher scores indicate better matches
- Use
start_ms
andend_ms
to create video clips - Cache search results for better performance