The Desearch API allows you to perform AI-powered web searches, gathering relevant information from multiple sources, including web pages, research papers, and social media discussions. This guide provides usage instructions, code samples, and parameter details to help you integrate the API into your applications.

Using Desearch AI Search API

The following examples demonstrate how to interact with the Desearch API using multiple coding platform.

Request Sample

The below scripts:

  • Sends a POST request to the AI-powered search API at https://apis.datura.ai/desearch/ai/search.

  • It includes an Authorization header with an API key and sets the Content-Type to “application/json”.

  • The request body contains parameters such as “date_filter”: “PAST_24_HOURS”, which limits results to the past 24 hours, and “model”: “NOVA”, specifying the AI model used.

  • The “prompt” field contains the search query “Tesla Space Program”, and “streaming”: False ensures non-streaming results.

  • The “tools” list specifies multiple data sources, including “Web Search”, “Hacker News Search”, “Reddit Search”, “Wikipedia Search”, “YouTube Search”, “Twitter Search”, and “ArXiv Search”.

  • The script sends the request , passing the url, payload, and headers, and then prints the raw response text.

    import requests

    url = "https://apis.datura.ai/desearch/ai/search"
    headers = {
        "Authorization": "<your-api-key>",
        "Content-Type": "application/json"
    }
    data = {
        "date_filter": "PAST_24_HOURS",
        "model": "NOVA",
        "prompt": "Tesla Space Program",
        "streaming": False,
        "tools": [
            "Web Search",
            "Hacker News Search",
            "Reddit Search",
            "Wikipedia Search",
            "Youtube Search",
            "Twitter Search",
            "ArXiv Search"
        ]
    }

    response = requests.post(url, json=data, headers=headers)
    print(response.json())

Parameters

Required

  • url: The endpoint for the Desearch API.
  • payload / body: A JSON string or dictionary containing:
    • prompt: A string representing the search query.
    • tools: A list of tools to be used for the search, e.g., [“Web Search”].
    • model: The model to be used for processing, e.g., “NOVA”.
    • date_filter: A string to filter search results by date, e.g., “PAST_24_HOURS”.

Optional

  • streaming: A boolean indicating whether to enable streaming responses. Defaults to true.

Response Sample

Based on the above code, here is how the response is retrieve as JSON. Each coding language has its own way of retrieving data from the below JSON.

{
  "reddit_search_results": {
    "organic_results": [
      {
        "title": "what is it about SpaceX that is fostering their success?",
        "link": "https://www.reddit.com/r/space/comments/1fdl7k4/"
      }
    ]
  },
  "hacker_news_search_results": {
    "organic_results": [
      {
        "title": "SpaceX runs as a giant R&D program",
        "link": "https://news.ycombinator.com/item?id=23370130"
      }
    ]
  },
  "completion": {
    "key_sources": [
      {
        "text": "SpaceX put a Tesla sportscar into space five years ago.",
        "url": "https://www.cnn.com/2023/02/06/world/spacex-elon-musk-tesla-roadster-five-years-scn/index.html"
      }
    ],
    "search_summary": "The Tesla Roadster launched by SpaceX is currently orbiting the Sun, traveling between Earth and Mars.",
    "key_tweets": [
      {
        "text": "Starship is key to making life multiplanetary.",
        "url": "https://x.com/teslaownersSV/status/1889722986036330565"
      }
    ],
    "key_news": [
      {
        "text": "SpaceX runs as a giant R&D program.",
        "url": "https://news.ycombinator.com/item?id=23370130"
      }
    ],
    "key_posts": [
      {
        "text": "What is it about SpaceX that is fostering success?",
        "url": "https://www.reddit.com/r/space/comments/1fdl7k4/"
      }
    ],
    "reddit_summary": "The Tesla Space Program showcases a synergy between automotive and aerospace innovation."
  }
}

Models

Nova 1.0

Quick insights, broad coverage.

Orbit 1.0

Balanced analysis, targeted relevance.

Horizon 1.0

In-depth exploration, profound insights.

Tools

Web Search

To find information and resources across the internet.

Reddit

To gather community-driven insights and discussions.

YouTube

For video content and tutorials.

Hacker News

To find tech-related news and discussions.

Wikipedia

For detailed and comprehensive information on a wide range of topics.

Twitter

To gather real-time updates and discussions.

arXiv

For accessing research papers and preprints in various fields.

Test API

To experiment with the Desearch AI Search and see it in action, visit the Desearch API.