Getting started
Install the exa-py SDKbash
Python
Get API Key
Follow this link to get your API key
search Method
Perform an Exa search given an input query and retrieve a list of relevant results as links.
Input Example
Python
Input Parameters
| Parameter | Type | Description | Default |
|---|---|---|---|
| query | str | The input query string. | Required |
| num_results | Optional[int] | Number of search results to return. | 10 |
| include_domains | Optional[List[str]] | List of domains to include in the search. | None |
| exclude_domains | Optional[List[str]] | List of domains to exclude in the search. | None |
| start_crawl_date | Optional[str] | Results will only include links crawled after this date. | None |
| end_crawl_date | Optional[str] | Results will only include links crawled before this date. | None |
| start_published_date | Optional[str] | Results will only include links with a published date after this date. | None |
| end_published_date | Optional[str] | Results will only include links with a published date before this date. | None |
| use_autoprompt | Optional[bool] | If true, convert query to a query best suited for Exa. | False |
| type | Optional[str] | The type of search, keyword or neural. | ”auto” |
| category | Optional[str] | A data category to focus on when searching, with higher comprehensivity and data cleanliness. Currently, the available categories are: company, research paper, news, github, tweet, movie, song, personal site, pdf | None |
Returns Example
Returns:JSON
Return Parameters
SearchResponse[Result]
| Field | Type | Description |
|---|---|---|
| results | List[Result] | List of Result objects |
| autoprompt_string | Optional[str] | Exa query created by autoprompt functionality |
Result Object
| Field | Type | Description |
|---|---|---|
| url | str | URL of the search result |
| id | str | Temporary ID for the document |
| title | Optional[str] | Title of the search result |
| score | Optional[float] | Similarity score between query/url and result |
| published_date | Optional[str] | Estimated creation date |
| author | Optional[str] | Author of the content, if available |
search_and_contents Method
Perform an Exa search given an input query and retrieve a list of relevant results as links, optionally including the full text and/or highlights of the content.
Input Example
Python
Input Parameters
| Parameter | Type | Description | Default |
|---|---|---|---|
| query | str | The input query string. | Required |
| text | Union[TextContentsOptions, Literal[True]] | If provided, includes the full text of the content in the results. | None |
| highlights | Union[HighlightsContentsOptions, Literal[True]] | If provided, includes highlights of the content in the results. | None |
| num_results | Optional[int] | Number of search results to return. | 10 |
| include_domains | Optional[List[str]] | List of domains to include in the search. | None |
| exclude_domains | Optional[List[str]] | List of domains to exclude in the search. | None |
| start_crawl_date | Optional[str] | Results will only include links crawled after this date. | None |
| end_crawl_date | Optional[str] | Results will only include links crawled before this date. | None |
| start_published_date | Optional[str] | Results will only include links with a published date after this date. | None |
| end_published_date | Optional[str] | Results will only include links with a published date before this date. | None |
| use_autoprompt | Optional[bool] | If true, convert query to a query best suited for Exa. | False |
| type | Optional[str] | The type of search, keyword or neural. | ”auto” |
| category | Optional[str] | A data category to focus on when searching, with higher comprehensivity and data cleanliness. Currently, the available categories are: company, research paper, news, github, tweet, movie, song, personal site, pdf | None |
Returns Example
JSON
Return Parameters
The return type depends on the combination oftext and highlights parameters:
SearchResponse[ResultWithText]: When onlytextis provided.SearchResponse[ResultWithHighlights]: When onlyhighlightsis provided.SearchResponse[ResultWithTextAndHighlights]: When bothtextandhighlightsare provided.
SearchResponse[ResultWithTextAndHighlights]
| Field | Type | Description |
|---|---|---|
| results | List[ResultWithTextAndHighlights] | List of ResultWithTextAndHighlights objects |
| autoprompt_string | Optional[str] | Exa query created by autoprompt functionality |
ResultWithTextAndHighlights Object
| Field | Type | Description |
|---|---|---|
| url | str | URL of the search result |
| id | str | Temporary ID for the document |
| title | Optional[str] | Title of the search result |
| score | Optional[float] | Similarity score between query/url and result |
| published_date | Optional[str] | Estimated creation date |
| author | Optional[str] | Author of the content, if available |
| text | str | Text of the search result page (always present) |
| highlights | List[str] | Highlights of the search result (always present) |
| highlight_scores | List[float] | Scores of the highlights (always present) |
text nor highlights is specified, the method defaults to including the full text content.
find_similar Method
Find a list of similar results based on a webpage’s URL.
Input Example
Python
Input Parameters
| Parameter | Type | Description | Default |
|---|---|---|---|
| url | str | The URL of the webpage to find similar results for. | Required |
| num_results | Optional[int] | Number of similar results to return. | None |
| include_domains | Optional[List[str]] | List of domains to include in the search. | None |
| exclude_domains | Optional[List[str]] | List of domains to exclude from the search. | None |
| start_crawl_date | Optional[str] | Results will only include links crawled after this date. | None |
| end_crawl_date | Optional[str] | Results will only include links crawled before this date. | None |
| start_published_date | Optional[str] | Results will only include links with a published date after this date. | None |
| end_published_date | Optional[str] | Results will only include links with a published date before this date. | None |
| exclude_source_domain | Optional[bool] | If true, excludes results from the same domain as the input URL. | None |
| category | Optional[str] | A data category to focus on when searching, with higher comprehensivity and data cleanliness. | None |
Returns Example
JSON
Return Parameters
SearchResponse[_Result]: The response containing similar results and optional autoprompt string.
SearchResponse[Results]
| Field | Type | Description |
|---|---|---|
| results | List[ResultWithTextAndHighlights] | List of ResultWithTextAndHighlights objects |
| autoprompt_string | Optional[str] | Exa query created by autoprompt functionality |
Results Object
| Field | Type | Description |
|---|---|---|
| url | str | URL of the search result |
| id | str | Temporary ID for the document |
| title | Optional[str] | Title of the search result |
| score | Optional[float] | Similarity score between query/url and result |
| published_date | Optional[str] | Estimated creation date |
| author | Optional[str] | Author of the content, if available |
find_similar_and_contents Method
Find a list of similar results based on a webpage’s URL, optionally including the text content or highlights of each result.
Input Example
Python
Input Parameters
| Parameter | Type | Description | Default |
|---|---|---|---|
| url | str | The URL of the webpage to find similar results for. | Required |
| text | Union[TextContentsOptions, Literal[True]] | If provided, includes the full text of the content in the results. | None |
| highlights | Union[HighlightsContentsOptions, Literal[True]] | If provided, includes highlights of the content in the results. | None |
| num_results | Optional[int] | Number of similar results to return. | None |
| include_domains | Optional[List[str]] | List of domains to include in the search. | None |
| exclude_domains | Optional[List[str]] | List of domains to exclude from the search. | None |
| start_crawl_date | Optional[str] | Results will only include links crawled after this date. | None |
| end_crawl_date | Optional[str] | Results will only include links crawled before this date. | None |
| start_published_date | Optional[str] | Results will only include links with a published date after this date. | None |
| end_published_date | Optional[str] | Results will only include links with a published date before this date. | None |
| exclude_source_domain | Optional[bool] | If true, excludes results from the same domain as the input URL. | None |
| category | Optional[str] | A data category to focus on when searching, with higher comprehensivity and data cleanliness. | None |
Returns
The return type depends on the combination oftext and highlights parameters:
SearchResponse[ResultWithText]: When onlytextis provided or when neithertextnorhighlightsis provided (defaults to including text).SearchResponse[ResultWithHighlights]: When onlyhighlightsis provided.SearchResponse[ResultWithTextAndHighlights]: When bothtextandhighlightsare provided.
text nor highlights is specified, the method defaults to including the full text content.
