---
title: "Search"
canonical: https://www.quantconnect.com/docs/v2/cloud-platform/api-reference/ai-assistance/tools/search
markdown: https://www.quantconnect.com/docs/v2/cloud-platform/api-reference/ai-assistance/tools/search.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/01%20Cloud%20Platform/99%20API%20Reference/10%20AI%20Assistance/02%20Tools/06%20Search
modified: 2026-10-31
index: https://www.quantconnect.com/llms.txt
---

# Search

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Cloud Platform](https://www.quantconnect.com/docs/v2/cloud-platform.md) > [API Reference](https://www.quantconnect.com/docs/v2/cloud-platform/api-reference.md) > [AI Assistance](https://www.quantconnect.com/docs/v2/cloud-platform/api-reference/ai-assistance.md) > [Tools](https://www.quantconnect.com/docs/v2/cloud-platform/api-reference/ai-assistance/tools.md) > Search

> Code examples are shown in Python. Append `?lang=csharp` to this URL for the C# version of this page.

## Introduction

Search for content in QuantConnect.

## Request

Search for content in QuantConnect. The `/ai/tools/search` API accepts requests in the following format:

| `SearchRequest` Model - Request to search content in QuantConnect. |  |
| --- | --- |
| language | `string Enum required example: Py` Programming language of the content to search. Options : ['C#', 'Py'] |
| criteria | `SearchCriteria Array required` Criteria for the search. |
| Example | `{ "language": "Py", "criteria": [ { "input": "option", "type": "Stubs", "count": 1 } ] }` |

| `SearchCriteria` Model - Search criteria. |  |
| --- | --- |
| input | `string required example: option` Input for the search. |
| type | `string Enum required` Type of the search criteria. Options : ['Stubs', 'Forum', 'Docs', 'Examples'] |
| count | `integer required example: 1` Number of results to return. |
| Example | `{ "input": "option", "type": "Stubs", "count": 1 }` |

## Responses

The `/ai/tools/search` API provides a response in the following format:

### 200 Success

| `SearchResponse` Model - Response to a search request. |  |
| --- | --- |
| state | `string Enum` State of the search. Options : ['End', 'Error'] |
| version | `number example: 2.0` Version of the response. |
| retrivals | `SearchRetrieval Array` List of search results. |
| messageId | `integer example: 0` Id of the message. |
| Example | `{ "state": "End", "version": 2.0, "retrivals": [ { "url": "[Index Options - QuantConnect.com](https://www.quantconnect.com/docs/v2/writing-algorithms/universes/index-options)", "score": 0.320344448, "content": "string", "type": 2 } ], "messageId": 0 }` |

| `SearchRetrieval` Model - Search criteria. |  |
| --- | --- |
| url | `string example: [Index Options - QuantConnect.com](https://www.quantconnect.com/docs/v2/writing-algorithms/universes/index-options)` Input for the search. |
| score | `number example: 0.320344448` Relevance score of the search result. |
| content | `string` Content of the search result. |
| type | `number example: 2` Type of the search result. 0=Stubs, 1=Forum, 2=Docs, 3=Examples. |
| Example | `{ "url": "[Index Options - QuantConnect.com](https://www.quantconnect.com/docs/v2/writing-algorithms/universes/index-options)", "score": 0.320344448, "content": "string", "type": 2 }` |

### 401 Authentication Error

| `UnauthorizedError` Model - Unauthorized response from the API. Key is missing, invalid, or timestamp is too old for hash. |  |
| --- | --- |
| www_authenticate | `string` Header |

## Examples

The following example demonstates searching content in QuantConnect through the cloud API.

```
from base64 import b64encode
from hashlib import sha256
from time import time
from requests import get, post
BASE_URL = 'https://www.quantconnect.com/api/v2/'

# You need to replace these with your actual credentials.
# You can request your credentials at https://www.quantconnect.com/settings/
# You can find our organization ID at https://www.quantconnect.com/organization/
USER_ID = 0
API_TOKEN = '____'
ORGANIZATION_ID = '____'

def get_headers():
    # Get timestamp
    timestamp = f'{int(time())}'
    time_stamped_token = f'{API_TOKEN}:{timestamp}'.encode('utf-8')

    # Get hased API token
    hashed_token = sha256(time_stamped_token).hexdigest()
    authentication = f'{USER_ID}:{hashed_token}'.encode('utf-8')
    authentication = b64encode(authentication).decode('ascii')

    # Create headers dictionary.
    return {
        'Authorization': f'Basic {authentication}',
        'Timestamp': timestamp
    }

# Authenticate to verify credentials
response = post(f'{BASE_URL}/authenticate', headers = get_headers())
print(response.json())

# --------------------

### Search Content
# Send a POST request to the /ai/tools/search endpoint to search content
response = post(f'{BASE_URL}/ai/tools/search', headers=get_headers(), json={
    "language": "Python",  # Programming language to filter search results
    "criteria": [  # Search criteria
        {
            "input": "option",  # Search term (e.g., "option")
            "type": "Docs",  # Type of content to search (e.g., documentation)
            "count": 1  # Number of results to return
        }
    ]
})
# Parse the JSON response into python managable dict
result = response.json()
# Check if the request was successful and print the search results
if result['success']:
    print("Search Results:")
    print(result)
```
