JavaScript SDK Specification
Enumeration of methods and types in the Desearch JavaScript SDK (desearch-js)
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.
Installation
To install the desearch-js
SDK, use the following command:
npm install desearch-js
Once installed, you can initialize the Desearch client as follows:
const desearch = require('desearch-js');
const desearch = new desearch('your-api-key');
API Keys
Get API Key (Follow link to get your API key) https://console.desearch.ai/api-keys.
Methods and Usage
The Desearch SDK provides the following methods for AI-powered search:
AISearch
Method
AISearch
MethodThe AISearch method allows users to perform AI-powered searches across multiple tools, retrieving links and summaries.
Example Usage
const aiSearchResult = await desearch.AISearch({
prompt: "Bittensor",
tools: [
"Web Search",
"Hacker News Search",
"Reddit Search",
"Wikipedia Search",
"Youtube Search",
"Twitter Search",
"ArXiv Search"
],
model: "NOVA",
date_filter: "PAST_24_HOURS",
streaming: false,
});
console.log(aiSearchResult);
Input Parameters
Parameter | Type | Description | Default |
---|---|---|---|
prompt | string | Search query prompt | Bittensor |
tools | List[string] | A list of tools to be used for the search | ["Web Search", "Hacker News Search", "Reddit Search", "Wikipedia Search", "Youtube Search", "Twitter Search", "ArXiv Search"] |
model | string | The model to be used for the search | NOVA |
date_filter | Optional[string] | The date filter to be used for the search | LINKS_FIRST |
streaming | Optional[bool] | Whether to stream results | True |
Sample Response
{
"youtube_search_results": {
"organic_results": [
{
"title": "Did The FED Do The Impossible? [Huge Implications For Bitcoin]",
"link": "https://www.youtube.com/watch?v=Ycq1u2zWfr8",
"snippet": "Did we avoid a recession and is there still more upside for Bitcoin? GET MY FREE NEWSLETTER ...",
"summary_description": "Did The FED Do The Impossible? [Huge Implications For Bitcoin]"
}
]
},
// ... other search results ...
}
Here are the details of above response.
- A JSON object mapping tool names to their search results: When only streaming is False
- StreamingResponse(text_chunks): When only streaming is True
twitterLinksSearch
Method
twitterLinksSearch
MethodThe TwitterLinksSearch method searches for relevant links from X (Twitter) based on AI-enhanced queries, leveraging AI-powered models.
Example Usage
const twitterLinksResult = await desearch.twitterLinksSearch({
prompt: "Bittensor",
model: "NOVA",
});
console.log(twitterLinksResult);
Input Parameters
Parameter | Type | Description | Default |
---|---|---|---|
prompt | string | Search query prompt | Bittensor |
model | string | The model to be used for the search | NOVA |
Sample Response
{
"miner_tweets": [
{
"user": {
"id": "123456789",
"url": "https://twitter.com/example_user",
"name": "John Doe",
"username": "johndoe",
"created_at": "2023-01-01T00:00:00Z",
"description": "This is an example user description.",
"favourites_count": 100,
"followers_count": 1500,
"listed_count": 10,
"media_count": 50,
"profile_image_url": "https://example.com/profile.jpg",
"statuses_count": 500,
"verified": true
},
"id": "987654321",
"text": "This is an example tweet.",
"reply_count": 10,
"retweet_count": 5,
"like_count": 100,
"view_count": 1000,
"quote_count": 2,
"impression_count": 1500,
"bookmark_count": 3,
"url": "https://twitter.com/example_tweet",
"created_at": "2023-01-01T00:00:00Z",
"media": [],
"is_quote_tweet": false,
"is_retweet": false,
"entities": {},
"summary_description": "This is a summary of the tweet."
}
]
}
basicWebSearch
Method
basicWebSearch
MethodThis API allows users to search for any information over the web. This replicates a typical search engine experience, where users can search for any information they need.
Example Usage
const basicWebResult = await desearch.basicWebSearch({
query: "Latest news on AI",
num: 10,
start: 0
});
console.log(basicWebResult);
Input Parameters
Parameter | Type | Description | Default |
---|---|---|---|
query | string | The search query for retrieving relevant web result | latest news on AI |
num | number | The number of search results to return | 10 |
start | number | The starting index for search results pagination | 0 |
Sample Response
{
"data": [
{
"title": "AI News & Artificial Intelligence | TechCrunch",
"snippet": "TechCrunch covers the latest news and trends on artificial intelligence and machine learning tech, the companies building them, and the ethical issues they raise. Find headlines, briefs, events, startups, and more on generative AI, speech recognition, predictive analytics, and more.",
"link": "https://techcrunch.com/category/artificial-intelligence/",
"date": null
},
{
"title": "The Latest AI News and Analysis - PCMag",
"snippet": "The ChatGPT maker calls for a ban on China-produced AI models 'that violate user privacy and create security risks such as the risk of IP theft.' But any ban would probably benefit OpenAI, too.",
"link": "https://www.pcmag.com/news/categories/ai",
"date": null
},
{
"title": "Artificial Intelligence News -- ScienceDaily",
"snippet": "Find the latest news and research on artificial intelligence, robotics, machine learning, and related fields. Browse headlines, summaries, and full articles from various sources and topics.",
"link": "https://www.sciencedaily.com/news/computers_math/artificial_intelligence/",
"date": null
},
{
"title": "AI News | Latest Headlines and Developments | Reuters",
"snippet": "India's central bank governor calls on banks to adopt AI to address consumer complaints. 4:27 PM UTC Technology category. ... Reuters, the news and media division of Thomson Reuters, is the world ...",
"link": "https://www.reuters.com/technology/artificial-intelligence/",
"date": null
},
{
"title": "Artificial Intelligence: Read latest news updates on AI technology ...",
"snippet": "Artificial Intelligence: Read latest updates on AI like Google AI, ChatGPT, Google Lamda, Bard chatbot and more along with latest news as AI technology advances and makes new progress. All get detailed articles on AI related queries like what is AI, types of artificial intelligence, its applications and future.",
"link": "https://indianexpress.com/section/technology/artificial-intelligence/",
"date": null
},
{
"title": "The latest AI news we announced in February - The Keyword",
"snippet": "Google shared its latest AI news from February, highlighting advancements in various fields. Google's CEO believes AI is the most profound shift in our lifetimes and is already unlocking benefits for people and society. Google launched a new AI tool called Career Dreamer to help people explore career possibilities and craft professional materials.",
"link": "https://blog.google/technology/ai/google-ai-updates-february-2025/",
"date": null
},
{
"title": "Google News - Artificial intelligence - Latest",
"snippet": "Google News - Artificial intelligence - Latest",
"link": "https://news.google.com/topics/CAAqJAgKIh5DQkFTRUFvSEwyMHZNRzFyZWhJRlpXNHRSMElvQUFQAQ",
"date": null
},
{
"title": "Artificial intelligence | AP News",
"snippet": "Don't miss an update on the latest artificial intelligence news from The Associated Press. Don't miss an update on the latest artificial intelligence news from The Associated Press. ... AI-created church service in Finland was quirky and fun but lacked human warmth, worshippers say. Paralyzed man moves robotic arm with his thoughts, thanks to ...",
"link": "https://apnews.com/hub/artificial-intelligence",
"date": null
},
{
"title": "Artificial Intelligence - Latest AI News and Analysis - WSJ.com",
"snippet": "The latest artificial intelligence news coverage focusing on the technology, tools and the companies building AI technology.",
"link": "https://www.wsj.com/tech/ai",
"date": null
},
{
"title": "Artificial intelligence - BBC News",
"snippet": "All the latest content about Artificial intelligence from the BBC.",
"link": "https://www.bbc.co.uk/news/topics/ce1qrvleleqt",
"date": null
}
]
}
basicTwitterSearch
Method
basicTwitterSearch
MethodThe Basic X (Twitter) Search API allows users to search for relevant links or tweets based on X (Twitter) search queries without leveraging AI-powered models.
Example Usage
const basicTwitterResult = await desearch.basicTwitterSearch({
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,
is_quote: true,
is_video: true,
is_image: true,
min_retweets: 1,
min_replies: 1,
min_likes: 1
count: 10
});
console.log(basicTwitterResult);
Input Parameters
Parameter | Type | Description | Default |
---|---|---|---|
query | string | Search query prompt | Whats going on with Bittensor |
sort | string | Sort order of the search results | Top |
user | string | User to search for tweets | elonmusk |
start_date | string | Start date for the search | 2024-12-01 |
end_date | string | End date for the search | 2025-02-25 |
lang | string | Language of the tweets | en |
verified | bool | Filter for verified users | true |
blue_verified | bool | Filter for blue verified users | true |
is_quote | bool | Filter for quoted tweets | true |
is_video | bool | Filter for video tweets | true |
is_image | bool | Filter for image tweets | true |
min_retweets | int | Minimum number of retweets | 1 |
min_replies | int | Minimum number of replies | 1 |
min_likes | int | Minimum number of likes | 1 |
count | int | Number of tweets to retrieve | 10 |
Sample Response
{
"user": {
"id": "1453417787746029577",
"url": "https://x.com/firsttensor",
"name": "Firsττensor - Biττensor Validator",
"username": "firsttensor",
"created_at": "2021-10-27",
"followers_count": 4669,
"profile_image_url": "https://pbs.twimg.com/profile_images/1890150870563614720/L3PGGoUs_normal.jpg"
},
"id": "1891203972003684353",
"text": "How to Stake/Unstake $TAO to the FirstTensor Validator Using the YUMA Platform.\n\n✅ Make sure your wallet is imported into the Polkadot.js or Bittensor Wallet extension.\n\n👇Share this so everyone can use it! \n\n#bittensor #delegate #root",
"retweet_count": 2,
"like_count": 7,
"created_at": "2025-02-16",
"url": "https://x.com/firsttensor/status/1891203972003684353",
"media": [
{
"media_url": "https://pbs.twimg.com/ext_tw_video_thumb/1891202584314105856/pu/img/nzOtIMS_Zz7YWHJY.jpg",
"type": "video"
}
],
"hashtags": ["bittensor", "delegate", "root"]
}
webLinksSearch
Method
webLinksSearch
MethodThis API allows users to search for links related to a given query using multiple tools, excluding X (Twitter) Search.
Example Usage
const webLinksResult = await desearch.webLinksSearch({
prompt: "Bittensor",
tools: [
"Web Search",
"Hacker News Search",
"Reddit Search",
"Wikipedia Search",
"Youtube Search",
"Twitter Search",
"ArXiv Search"
],
model: "NOVA",
});
console.log(webLinksResult);
Input Parameters
Parameter | Type | Description | Default |
---|---|---|---|
prompt | string | Search query prompt | Bittensor |
model | string | The model to be used for the search | NOVA |
tools | List[string] | List of tools to search with An enumeration. | [ "Web Search", "Hacker News Search","Reddit Search","Wikipedia Search","Youtube Search","Twitter Search", "ArXiv Search"] |
Sample Response
{
"data": [
{
"title": "AI News & Artificial Intelligence | TechCrunch",
"snippet": "TechCrunch covers the latest news and trends on artificial intelligence and machine learning tech, the companies building them, and the ethical issues they raise. Find headlines, briefs, events, startups, and more on generative AI, speech recognition, predictive analytics, and more.",
"link": "https://techcrunch.com/category/artificial-intelligence/",
"date": null
},
{
"title": "The Latest AI News and Analysis - PCMag",
"snippet": "The ChatGPT maker calls for a ban on China-produced AI models 'that violate user privacy and create security risks such as the risk of IP theft.' But any ban would probably benefit OpenAI, too.",
"link": "https://www.pcmag.com/news/categories/ai",
"date": null
},
{
"title": "Artificial Intelligence News -- ScienceDaily",
"snippet": "Find the latest news and research on artificial intelligence, robotics, machine learning, and related fields. Browse headlines, summaries, and full articles from various sources and topics.",
"link": "https://www.sciencedaily.com/news/computers_math/artificial_intelligence/",
"date": null
},
{
"title": "AI News | Latest Headlines and Developments | Reuters",
"snippet": "India's central bank governor calls on banks to adopt AI to address consumer complaints. 4:27 PM UTC Technology category. ... Reuters, the news and media division of Thomson Reuters, is the world ...",
"link": "https://www.reuters.com/technology/artificial-intelligence/",
"date": null
},
{
"title": "Artificial Intelligence: Read latest news updates on AI technology ...",
"snippet": "Artificial Intelligence: Read latest updates on AI like Google AI, ChatGPT, Google Lamda, Bard chatbot and more along with latest news as AI technology advances and makes new progress. All get detailed articles on AI related queries like what is AI, types of artificial intelligence, its applications and future.",
"link": "https://indianexpress.com/section/technology/artificial-intelligence/",
"date": null
},
{
"title": "The latest AI news we announced in February - The Keyword",
"snippet": "Google shared its latest AI news from February, highlighting advancements in various fields. Google's CEO believes AI is the most profound shift in our lifetimes and is already unlocking benefits for people and society. Google launched a new AI tool called Career Dreamer to help people explore career possibilities and craft professional materials.",
"link": "https://blog.google/technology/ai/google-ai-updates-february-2025/",
"date": null
},
{
"title": "Google News - Artificial intelligence - Latest",
"snippet": "Google News - Artificial intelligence - Latest",
"link": "https://news.google.com/topics/CAAqJAgKIh5DQkFTRUFvSEwyMHZNRzFyZWhJRlpXNHRSMElvQUFQAQ",
"date": null
},
{
"title": "Artificial intelligence | AP News",
"snippet": "Don't miss an update on the latest artificial intelligence news from The Associated Press. Don't miss an update on the latest artificial intelligence news from The Associated Press. ... AI-created church service in Finland was quirky and fun but lacked human warmth, worshippers say. Paralyzed man moves robotic arm with his thoughts, thanks to ...",
"link": "https://apnews.com/hub/artificial-intelligence",
"date": null
},
{
"title": "Artificial Intelligence - Latest AI News and Analysis - WSJ.com",
"snippet": "The latest artificial intelligence news coverage focusing on the technology, tools and the companies building AI technology.",
"link": "https://www.wsj.com/tech/ai",
"date": null
},
{
"title": "Artificial intelligence - BBC News",
"snippet": "All the latest content about Artificial intelligence from the BBC.",
"link": "https://www.bbc.co.uk/news/topics/ce1qrvleleqt",
"date": null
}
]
}
Updated about 11 hours ago