Setup

To get started, we need an API key that can be obtained by creating an account at https://app.askvideos.com.

Once that is done, the API can be accessed via:

  1. REST API
  2. Python client

For this tutorial, we will use the python client.

import askvideos as av
import requests

API_KEY = 'YOUR_API_KEY'
client = av.Client(API_KEY)
Follow these steps to get an API key: API keys

Creating an index

First, we will create an index to add videos to.

index_name = "test_index_add_videos"
client.create_index(index_name)

Adding videos from a file

# Path to video on local filesystem.
video_file = '/path/to/video_file.mp4'

# Optionally add transcripts in .vtt format.
transcript_path = '/path/to/transcript.vtt'

# Add metadata for this video.
metadata = {
    'title': 'Example video',
    'description': 'This is an example video',
    'info': {
        # Add any other info here. 
    }
}

client.index_video(index_name,
                    video_file=video_file,
                    transcript_path=transcript_path,
                    metadata=metadata)

Adding videos from a URL

# Path to video on local filesystem.
video_url = 'https://link.to/video.mp4'

# Add metadata for this video.
metadata = {
    'title': 'Example video',
    'description': 'This is an example video',
    'info': {
        # Add any other info here. 
    }
}

client.index_video(index_name,
                    video_url=video_url,
                    metadata=metadata)

Adding videos from YouTube

AskVideos provides convenience functions to index videos from YouTube. Please comply with your local laws for use of video content.

Next steps

Now that the index contains a few videos, we can do some cool things with the index.