> ## Documentation Index
> Fetch the complete documentation index at: https://docs.askvideos.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Search for moments

> Find exact moments across videos in the index

<Note>Try out the search function on a sample index in the [Search playground](https://app.askvideos.com/playground)</Note>

## Setup

<Steps>
  <Step title="Create an API key">
    First create an API key using the instructions in [API keys](/installation/api-key)
  </Step>

  <Step title="Install the client">
    Next install the AskVideos client if using [Python](/installation/python). Or consult the [REST API](/api-reference/introduction) reference for other frameworks.
  </Step>

  <Step title="Create an index">
    Next, [create an index](/quickstart/add-videos#creating-an-index). For this tutorial, we will use an index with the name 'test\_index'
  </Step>

  <Step title="Add some videos">
    Next, [add some videos](/quickstart/add-videos) to the index. Now we are ready to get started with searching!
  </Step>
</Steps>

## Search using text

```python theme={null}
index_name = 'test_index'
query = 'dogs running around'
top_k = 30 # Number of results to return.

results = client.search_videos(
            index_name,
            query,
            top_k=top_k)
```

The returned results look like this:

```json theme={null}
{
    "6689571-hd_1280_720_25fps": [
        {
            "score": 0.09953739908006456,
            "start_seconds": 0,
            "end_seconds": 18
        }
    ],
    "855386-hd_1280_720_25fps": [
        {
            "score": 0.10187351703643799,
            "start_seconds": 0,
            "end_seconds": 2
        },
        {
            "score": 0.08336693048477173,
            "start_seconds": 2,
            "end_seconds": 6
        },
        {
            "score": 0.10038037598133087,
            "start_seconds": 6,
            "end_seconds": 10
        }
    ]
    ...
}
```

Where the results are a dictionary of lists where the key of the dictionary is the `video_id` and the list items are segments of the video that are in the `top_k` results.

Each segment contains a score representing how close of a match the segment is to the query and the start and end timestamps within the video.

## Search using an image

```python theme={null}
index_name = 'test_index'
image_path = '/path/to/image.jpg'
top_k = 30 # Number of results to return.

results = client.search_by_image(
            image_path,
            query,
            top_k=top_k)
```

## Search using a video

```python theme={null}
index_name = 'test_index'
video_path = '/path/to/video.mp4'
top_k = 30 # Number of results to return.

results = client.search_by_video(
            index_name,
            video_path,
            top_k=top_k)
```

## Next steps

In addition to finding moments, AskVideos can also answer questions based on the videos in the index.

<CardGroup>
  <Card title="Generate answers" icon="question" href="/quickstart/answer">
    Ask questions and generate answers from video content.
  </Card>
</CardGroup>
