The Desearch JavaScript SDK provides a seamless way to integrate AI-powered search functionalities into your applications. This guide outlines the installation process, available methods, and example implementations.
To install the desearch-js SDK, use the following command:
Once installed, you can initialize the Desearch client as follows:
📘 API Keys
Get API Key (Follow link to get your API key) https://console.desearch.ai/api-keys.
The Desearch SDK provides the following methods for AI-powered search:
aiSearch MethodAI-powered multi-source contextual search. Searches across web, X (Twitter), Reddit, YouTube, HackerNews, Wikipedia, and arXiv and returns results with optional AI-generated summaries.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
prompt | string | Yes | — | Search query prompt |
tools | (ToolEnum | string)[] | Yes | — | A list of tools to be used for the search |
start_date | string | null | No | null | The start date for the search query (YYYY-MM-DDTHH:MM:SSZ) |
end_date | string | null | No | null | The end date for the search query (YYYY-MM-DDTHH:MM:SSZ) |
date_filter | DateFilterEnum | null | No | 'PAST_24_HOURS' | Predefined date filter for search results |
result_type | ResultTypeEnum | null | No | 'LINKS_WITH_FINAL_SUMMARY' | The result type for the search |
system_message | string | null | No | '' | System message for the search |
scoring_system_message | string | null | No | null | System message for scoring the response |
count | number | null | No | 10 | Number of results per source (10–200) |
aiWebLinksSearch MethodSearch for raw links across web sources (web, HackerNews, Reddit, Wikipedia, YouTube, arXiv). Returns structured link results without AI summaries.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
prompt | string | Yes | — | Search query prompt |
tools | (WebToolEnum | string)[] | Yes | — | List of tools to search with |
count | number | null | No | 10 | Number of results per source (10–200) |
aiXLinksSearch MethodSearch for X (Twitter) post links matching a prompt using AI-powered models. Returns tweet objects from the miner network.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
prompt | string | Yes | — | Search query prompt |
count | number | null | No | 10 | Number of results per source (10–200) |
xSearch MethodX (Twitter) search with extensive filtering options: date range, user, language, verification status, media type (image/video/quote), and engagement thresholds (min likes, retweets, replies). Sort by Top or Latest.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
query | string | Yes | — | Advanced search query |
sort | string | null | No | 'Top' | Sort by Top or Latest |
user | string | null | No | null | User to search for |
start_date | string | null | No | null | Start date in UTC (YYYY-MM-DD) |
end_date | string | null | No | null | End date in UTC (YYYY-MM-DD) |
lang | string | null | No | null | Language code (e.g., en, es, fr) |
verified | boolean | null | No | null | Filter for verified users |
blue_verified | boolean | null | No | null | Filter for blue checkmark verified users |
is_quote | boolean | null | No | null | Include only tweets with quotes |
is_video | boolean | null | No | null | Include only tweets with videos |
is_image | boolean | null | No | null | Include only tweets with images |
min_retweets | number | string | null | No | null | Minimum number of retweets |
min_replies | number | string | null | No | null | Minimum number of replies |
min_likes | number | string | null | No | null | Minimum number of likes |
count | number | null | No | 20 | Number of tweets to retrieve (1–100) |
xPostsByUrls MethodFetch full post data for a list of X (Twitter) post URLs. Returns metadata, content, and engagement metrics for each URL.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
urls | string[] | Yes | — | List of post URLs to retrieve |
xPostById MethodFetch a single X (Twitter) post by its unique ID. Returns metadata, content, and engagement metrics.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
id | string | Yes | — | The unique ID of the post |
xPostsByUser MethodSearch X (Twitter) posts by a specific user, with optional keyword filtering.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
user | string | Yes | — | User to search for |
query | string | No | '' | Advanced search query |
count | number | No | 10 | Number of tweets to retrieve (1–100) |
xPostRetweeters MethodRetrieve the list of users who retweeted a specific post by its ID. Supports cursor-based pagination.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
id | string | Yes | — | The ID of the post to get retweeters for |
cursor | string | null | No | null | Cursor for pagination |
xUserPosts MethodRetrieve a user's timeline posts by their username. Fetches the latest tweets posted by that user. Supports cursor-based pagination.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
username | string | Yes | — | Username to fetch posts for |
cursor | string | null | No | null | Cursor for pagination |
xUserReplies MethodFetch tweets and replies posted by a specific user, with optional keyword filtering.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
user | string | Yes | — | The username of the user to search for |
count | number | No | 10 | The number of tweets to fetch (1–100) |
query | string | No | '' | Advanced search query |
xPostReplies MethodFetch replies to a specific X (Twitter) post by its post ID.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
post_id | string | Yes | — | The ID of the post to search for |
count | number | No | 10 | The number of tweets to fetch (1–100) |
query | string | No | '' | Advanced search query |
xTrends MethodRetrieve trending topics on X for a given location using its WOEID (Where On Earth ID).
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
woeid | number | Yes | — | The WOEID of the location (e.g. 23424977 for United States) |
count | number | null | No | 30 | The number of trends to return (30–100) |
webSearch MethodSERP web search. Returns paginated web search results, replicating a typical search engine experience.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
query | string | Yes | — | The search query string |
start | number | No | 0 | How many results to skip for pagination (0, 10, 20, etc.) |
webCrawl MethodCrawl a URL and return its content as plain text or HTML.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
url | string | Yes | — | URL to crawl |
format | 'html' | 'text' | No | 'text' | Format of the content to be returned |