Python SDK Specification
Enumeration of methods and types in the Exa Python SDK (exa_py).
For ChatGPT-based Python SDK assistance, go here.
Getting started
Install the exa-py SDK
and then instantiate an Exa client
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
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, linkedin profile, github, tweet, movie, song, personal site, pdf and financial report. | None |
Returns Example
Returns:
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
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, linkedin profile, github, tweet, movie, song, personal site, pdf and financial report. | None |
Returns Example
Return Parameters
The return type depends on the combination of text
and highlights
parameters:
SearchResponse[ResultWithText]
: When onlytext
is provided.SearchResponse[ResultWithHighlights]
: When onlyhighlights
is provided.SearchResponse[ResultWithTextAndHighlights]
: When bothtext
andhighlights
are 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) |
Note: If neither 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
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
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
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 of text
and highlights
parameters:
SearchResponse[ResultWithText]
: When onlytext
is provided or when neithertext
norhighlights
is provided (defaults to including text).SearchResponse[ResultWithHighlights]
: When onlyhighlights
is provided.SearchResponse[ResultWithTextAndHighlights]
: When bothtext
andhighlights
are provided.
The response contains similar results and an optional autoprompt string.
Note: If neither text
nor highlights
is specified, the method defaults to including the full text content.