TypeScript SDK Specification
For ChatGPT-based TypeScript SDK assistance, go here.
Getting started
Installing the exa-js 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 | string | The input query string. | Required |
numResults | number | Number of search results to return. | 10 |
includeDomains | string[] | List of domains to include in the search. | undefined |
excludeDomains | string[] | List of domains to exclude in the search. | undefined |
startCrawlDate | string | Results will only include links crawled after this date. | undefined |
endCrawlDate | string | Results will only include links crawled before this date. | undefined |
startPublishedDate | string | Results will only include links with a published date after this date. | undefined |
endPublishedDate | string | Results will only include links with a published date before this date. | undefined |
useAutoprompt | boolean | If true, convert query to a query best suited for Exa. | false |
type | string | The type of search, “keyword” or “neural”. | “auto” |
category | string | \ data category to focus on when searching, with higher comprehensivity and data cleanliness. Available categories: “company”, “research paper”, “news”, “linkedin profile”, “github”, “tweet”, “movie”, “song”, “personal site”, “pdf”, “financial report”. | undefined |
Returns Example
Return Parameters
SearchResponse
Field | Type | Description |
---|---|---|
results | Result[] | List of Result objects |
autopromptString? | string | Exa query created by autoprompt functionality |
Result Object
Field | Type | Description | |
---|---|---|---|
url | string | URL of the search result | |
id | string | Temporary ID for the document | |
title | `string | null` | Title of the search result |
score? | number | Similarity score between query/url and result | |
publishedDate? | string | Estimated creation date | |
author? | string | Author of the content, if available |
searchAndContents
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 | string | The input query string. | Required | |
text | `boolean | { maxCharacters?: number, includeHtmlTags?: boolean } ` | If provided, includes the full text of the content in the results. | undefined |
highlights | `boolean | { query?: string, numSentences?: number, highlightsPerUrl?: number } ` | If provided, includes highlights of the content in the results. | undefined |
numResults | number | Number of search results to return. | 10 | |
includeDomains | string[] | List of domains to include in the search. | undefined | |
excludeDomains | string[] | List of domains to exclude in the search. | undefined | |
startCrawlDate | string | Results will only include links crawled after this date. | undefined | |
endCrawlDate | string | Results will only include links crawled before this date. | undefined | |
startPublishedDate | string | Results will only include links with a published date after this date. | undefined | |
endPublishedDate | string | Results will only include links with a published date before this date. | undefined | |
useAutoprompt | boolean | If true, convert query to a query best suited for Exa. | false | |
type | string | The type of search, “keyword” or “neural”. | “auto” | |
category | string | A data category to focus on when searching, with higher comprehensivity and data cleanliness. Available categories: “company”, “research paper”, “news”, “linkedin profile”, “github”, “tweet”, “movie”, “song”, “personal site”, “pdf” and “financial report”. | undefined |
Returns Example
Return Parameters
SearchResponse
Field | Type | Description |
---|---|---|
results | SearchResult<T>[] | List of SearchResult objects |
autopromptString? | string | Exa query created by autoprompt functionality |
SearchResult
Extends the Result
object from the search
method with additional fields based on T
:
Field | Type | Description |
---|---|---|
text? | string | Text of the search result page (if requested) |
highlights? | string[] | Highlights of the search result (if requested) |
highlightScores? | number[] | Scores of the highlights (if requested) |
Note: The actual fields present in the SearchResult<T>
object depend on the options provided in the searchAndContents
call.
findSimilar
Method
Find a list of similar results based on a webpage’s URL.
Input Example
Input Parameters
Parameter | Type | Description | Default |
---|---|---|---|
url | string | The URL of the webpage to find similar results for. | Required |
numResults | number | Number of similar results to return. | undefined |
includeDomains | string[] | List of domains to include in the search. | undefined |
excludeDomains | string[] | List of domains to exclude from the search. | undefined |
startCrawlDate | string | Results will only include links crawled after this date. | undefined |
endCrawlDate | string | Results will only include links crawled before this date. | undefined |
startPublishedDate | string | Results will only include links with a published date after this date. | undefined |
endPublishedDate | string | Results will only include links with a published date before this date. | undefined |
excludeSourceDomain | boolean | If true, excludes results from the same domain as the input URL. | undefined |
category | string | A data category to focus on when searching, with higher comprehensivity and data cleanliness. | undefined |
Returns Example
Return Parameters
SearchResponse
Field | Type | Description |
---|---|---|
results | Result[] | List of Result objects |
autopromptString? | string | Exa query created by autoprompt functionality |
Result Object
Field | Type | Description | |
---|---|---|---|
url | string | URL of the search result | |
id | string | Temporary ID for the document | |
title | `string | null` | Title of the search result |
score? | number | Similarity score between query/url and result | |
publishedDate? | string | Estimated creation date | |
author? | string | Author of the content, if available |
findSimilarAndContents
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 | string | The URL of the webpage to find similar results for. | Required | |
text | `boolean | { maxCharacters?: number, includeHtmlTags?: boolean } ` | If provided, includes the full text of the content in the results. | undefined |
highlights | `boolean | { query?: string, numSentences?: number, highlightsPerUrl?: number } ` | If provided, includes highlights of the content in the results. | undefined |
numResults | number | Number of similar results to return. | undefined | |
includeDomains | string[] | List of domains to include in the search. | undefined | |
excludeDomains | string[] | List of domains to exclude from the search. | undefined | |
startCrawlDate | string | Results will only include links crawled after this date. | undefined | |
endCrawlDate | string | Results will only include links crawled before this date. | undefined | |
startPublishedDate | string | Results will only include links with a published date after this date. | undefined | |
endPublishedDate | string | Results will only include links with a published date before this date. | undefined | |
excludeSourceDomain | boolean | If true, excludes results from the same domain as the input URL. | undefined | |
category | string | A data category to focus on when searching, with higher comprehensivity and data cleanliness. | undefined |
Returns Example
Return Parameters
SearchResponse
Field | Type | Description |
---|---|---|
results | SearchResult<T>[] | List of SearchResult objects |
autopromptString? | string | Exa query created by autoprompt functionality |
SearchResult
Extends the Result
object with additional fields based on the requested content:
Field | Type | Description | |
---|---|---|---|
url | string | URL of the search result | |
id | string | Temporary ID for the document | |
title | `string | null` | Title of the search result |
score? | number | Similarity score between query/url and result | |
publishedDate? | string | Estimated creation date | |
author? | string | Author of the content, if available | |
text? | string | Text of the search result page (if requested) | |
highlights? | string[] | Highlights of the search result (if requested) | |
highlightScores? | number[] | Scores of the highlights (if requested) |
Note: The actual fields present in the SearchResult<T>
object depend on the options provided in the findSimilarAndContents
call.
getContents
Method
Retrieves contents of documents based on a list of document IDs.
Input Example
Input Parameters
Parameter | Type | Description | Default | ||
---|---|---|---|---|---|
ids | `string | string[] | SearchResult[]` | A single ID, an array of IDs, or an array of SearchResults. | Required |
text | `boolean | { maxCharacters?: number, includeHtmlTags?: boolean } ` | If provided, includes the full text of the content in the results. | undefined | |
highlights | `boolean | { query?: string, numSentences?: number, highlightsPerUrl?: number } ` | If provided, includes highlights of the content in the results. | undefined |
Returns Example
Return Parameters
SearchResponse
Field | Type | Description |
---|---|---|
results | SearchResult<T>[] | List of SearchResult objects |
SearchResult
The fields in the SearchResult<T>
object depend on the options provided in the getContents
call:
Field | Type | Description | |
---|---|---|---|
id | string | Temporary ID for the document | |
url | string | URL of the search result | |
title | `string | null` | Title of the search result |
publishedDate? | string | Estimated creation date | |
author? | string | Author of the content, if available | |
text? | string | Text of the search result page (if requested) | |
highlights? | string[] | Highlights of the search result (if requested) | |
highlightScores? | number[] | Scores of the highlights (if requested) |
Note: The actual fields present in the SearchResult<T>
object depend on the options provided in the getContents
call. If neither text
nor highlights
is specified, the method defaults to including the full text content.