Skip to main content

Overview

In addition to online videos, VidNavigator allows you to upload and process your own local audio and video files. This is useful for analyzing private content or files that are not publicly available on the web.

Prerequisites

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

Organizing Files with Namespaces

You can organize your uploaded files into namespaces (like folders). When uploading, pass namespace_ids to assign the file to one or more namespaces. You can also manage namespaces later via the namespace endpoints. All file responses (list, info, search) now include namespace_ids and namespaces fields showing which namespaces each file belongs to.

Uploading a File

The file upload process is asynchronous by default, meaning the API will return a file ID immediately, and the file will be processed in the background. You can then use the file ID to check the status of the processing and retrieve the results once it’s complete.

Using the Python SDK

from vidnavigator import VidNavigatorClient, VidNavigatorError

client = VidNavigatorClient()

try:
    response = client.upload_file("path/to/your/video.mp4")
    print(f"File uploaded successfully. File ID: {response['file_id']}")
except FileNotFoundError:
    print("Error: The file was not found at the specified path.")
except VidNavigatorError as e:
    print(f"An error occurred: {e.message}")

Using the JavaScript SDK

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

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

async function uploadFile() {
  const filePath = "path/to/your/video.mp4";
  if (!fs.existsSync(filePath)) {
    console.error("Error: The file was not found at the specified path.");
    return;
  }

  try {
    const response = await client.uploadFile({ filePath });
    console.log(`File uploaded successfully. File ID: ${response.file_id}`);
  } catch (error) {
    if (error instanceof VidNavigatorError) {
      console.error(`An error occurred: ${error.message}`);
    } else {
      console.error("An unexpected error occurred:", error);
    }
  }
}

uploadFile();

Next Steps

Once your file is uploaded and processed, you can: