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 Key: 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

The 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

ParameterTypeDescriptionDefault
promptstringSearch query promptBittensor
toolsList[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”]
modelstringThe model to be used for the searchNOVA
date_filterOptional[string]The date filter to be used for the searchLINKS_FIRST
streamingOptional[bool]Whether to stream resultsTrue

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

The twitterLinksSearch method searches for relevant links from X (Twitter) based on AI-enhanced queries with leveraging AI-powered models.

Example Usage

    const twitterLinksResult = await desearch.twitterLinksSearch({
        prompt: "Bittensor",
        model: "NOVA",
    });
    console.log(twitterLinksResult);

Input Parameters

ParameterTypeDescriptionDefault
promptstringSearch query promptBittensor
modelstringThe model to be used for the searchNOVA

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

This 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

ParameterTypeDescriptionDefault
querystringThe search query for retrieving relevant web resultlatest news on AI
numnumberThe number of search results to return10
startnumberThe starting index for search results pagination0

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

The 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

ParameterTypeDescriptionDefault
querystringSearch query promptWhats going on with Bittensor
sortstringSort order of the search resultsTop
userstringUser to search for tweetselonmusk
start_datestringStart date for the search2024-12-01
end_datestringEnd date for the search2025-02-25
langstringLanguage of the tweetsen
verifiedboolFilter for verified userstrue
blue_verifiedboolFilter for blue verified userstrue
is_quoteboolFilter for quoted tweetstrue
is_videoboolFilter for video tweetstrue
is_imageboolFilter for image tweetstrue
min_retweetsintMinimum number of retweets1
min_repliesintMinimum number of replies1
min_likesintMinimum number of likes1
countintNumber of tweets to retrieve10

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

This 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

ParameterTypeDescriptionDefault
promptstringSearch query promptBittensor
modelstringThe model to be used for the searchNOVA
toolsList[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
            }
        ]
    }