Skip to main content

Overview

VidNavigator’s semantic search allows you to find relevant information within your video content without having to manually sift through hours of footage. You can search across a library of online videos (like YouTube) or your own uploaded files.

Prerequisites

  • A valid VidNavigator API key.
  • The Python or JavaScript SDK installed in your project.

Searching Videos

Searching Across Online Videos

This example demonstrates how to search for videos on YouTube that match a specific query.

Using the Python SDK

from vidnavigator import VidNavigatorClient, VidNavigatorError

client = VidNavigatorClient()

try:
    results = client.search_videos(
        query="What are the best practices for React development?",
        focus="relevance",
        start_year=2022
    )
    print(f"Found {len(results.data['results'])} relevant videos:")
    for video in results.data['results']:
        print(f"- {video['title']} ({video['url']})")
except VidNavigatorError as e:
    print(f"An error occurred: {e.message}")

Using the JavaScript SDK

const { VidNavigatorClient, VidNavigatorError } = require('vidnavigator');

const client = new VidNavigatorClient({
  apiKey: process.env.VIDNAVIGATOR_API_KEY,
});

async function searchOnlineVideos() {
  try {
    const results = await client.searchVideos({
      query: "What are the best practices for React development?",
      focus: "relevance",
      start_year: 2022
    });
    console.log(`Found ${results.data.results.length} relevant videos:`);
    results.data.results.forEach(video => {
      console.log(`- ${video.title} (${video.url})`);
    });
  } catch (error) {
    if (error instanceof VidNavigatorError) {
      console.error(`An error occurred: ${error.message}`);
    } else {
      console.error("An unexpected error occurred:", error);
    }
  }
}

searchOnlineVideos();

Searching Your Uploaded Files

This example demonstrates how to search across the files you have uploaded to VidNavigator.

Using the Python SDK

from vidnavigator import VidNavigatorClient, VidNavigatorError

client = VidNavigatorClient()

try:
    results = client.search_files(query="Customer feedback on pricing")
    print(f"Found {len(results.data['results'])} relevant files:")
    for file_result in results.data['results']:
        print(f"- {file_result['name']} (File ID: {file_result['id']})")
except VidNavigatorError as e:
    print(f"An error occurred: {e.message}")

Using the JavaScript SDK

const { VidNavigatorClient, VidNavigatorError } = require('vidnavigator');

const client = new VidNavigatorClient({
  apiKey: process.env.VIDNAVIGATOR_API_KEY,
});

async function searchUploadedFiles() {
  try {
    const results = await client.searchFiles({ query: "Customer feedback on pricing" });
    console.log(`Found ${results.results.length} relevant files:`);
    results.results.forEach(fileResult => {
      console.log(`- ${fileResult.name} (File ID: ${fileResult.id})`);
    });
  } catch (error) {
    if (error instanceof VidNavigatorError) {
      console.error(`An error occurred: ${error.message}`);
    } else {
      console.error("An unexpected error occurred:", error);
    }
  }
}

searchUploadedFiles();