The official JavaScript SDK for the Desearch API - AI-driven search, web crawling, and X (Twitter) data extraction.
- Installation
- Quick Start
- AI Contextual Search
- AI Web Links Search
- AI X Posts Links Search
- X Search
- Fetch Posts by URLs
- Retrieve Post by ID
- Search X Posts by User
- Get Retweeters of a Post
- Get X Posts by Username
- Fetch User's Tweets and Replies
- Retrieve Replies for a Post
- Get X Trends
- SERP Web Search
- Crawl a URL
- Links
npm install desearch-jsimport Desearch from "desearch-js";
const desearch = new Desearch("your-api-key");
// Perform an AI-powered search
desearch
.aiSearch({
prompt: "Latest developments in AI",
tools: ["web", "twitter", "reddit"],
})
.then((response) => {
console.log(response);
});aiSearch
AI-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) |
desearch
.aiSearch({
prompt: "Bittensor",
tools: ["web", "hackernews", "reddit", "wikipedia", "youtube", "twitter", "arxiv"],
date_filter: "PAST_24_HOURS",
result_type: "LINKS_WITH_FINAL_SUMMARY",
count: 20,
})
.then((result) => {
console.log(result);
});aiWebLinksSearch
Search 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) |
desearch
.aiWebLinksSearch({
prompt: "What are the recent sport events?",
tools: ["web", "hackernews", "reddit", "wikipedia", "youtube", "arxiv"],
count: 20,
})
.then((result) => {
console.log(result);
});aiXLinksSearch
Search 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) |
desearch
.aiXLinksSearch({
prompt: "What are the recent sport events?",
count: 20,
})
.then((result) => {
console.log(result);
});xSearch
X (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) |
desearch
.xSearch({
query: "Whats going on with Bittensor",
sort: "Top",
user: "elonmusk",
start_date: "2024-12-01",
end_date: "2025-02-25",
lang: "en",
verified: true,
blue_verified: true,
count: 20,
})
.then((result) => {
console.log(result);
});xPostsByUrls
Fetch 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 |
desearch
.xPostsByUrls({
urls: ["https://x.com/RacingTriple/status/1892527552029499853"],
})
.then((result) => {
console.log(result);
});xPostById
Fetch 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 |
desearch
.xPostById({
id: "1892527552029499853",
})
.then((result) => {
console.log(result);
});xPostsByUser
Search 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) |
desearch
.xPostsByUser({
user: "elonmusk",
query: "Whats going on with Bittensor",
count: 20,
})
.then((result) => {
console.log(result);
});xPostRetweeters
Retrieve 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 |
desearch
.xPostRetweeters({
id: "1982770537081532854",
})
.then((result) => {
console.log(result);
});xUserPosts
Retrieve 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 |
desearch
.xUserPosts({
username: "elonmusk",
})
.then((result) => {
console.log(result);
});xUserReplies
Fetch 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 |
desearch
.xUserReplies({
user: "elonmusk",
count: 20,
query: "latest news on AI",
})
.then((result) => {
console.log(result);
});xPostReplies
Fetch 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 |
desearch
.xPostReplies({
post_id: "1234567890",
count: 20,
query: "latest news on AI",
})
.then((result) => {
console.log(result);
});xTrends
Retrieve 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) |
desearch
.xTrends({
woeid: 23424977,
count: 20,
})
.then((result) => {
console.log(result);
});webSearch
SERP 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.) |
desearch
.webSearch({
query: "latest news on AI",
start: 10,
})
.then((result) => {
console.log(result);
});webCrawl
Crawl 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 |
desearch
.webCrawl({
url: "https://en.wikipedia.org/wiki/Artificial_intelligence",
format: "html",
})
.then((result) => {
console.log(result);
});