Basic Web Search

Web search API allows you to search the web for information similar to a search engine.


This API allows users to search for any information on the web. This replicates a typical search engine experience, where users can search for any information they need.

Using the Basic Web Search API

The following examples demonstrate how to interact with the Basic Web Search API using multiple programming languages and platforms.

Request Sample

The below code snippet:

  • Sends an HTTP GET request to the https://apis.datura.ai/web API to retrieve the latest news related to AI.

  • The script defines the API endpoint and sets query parameters, including a search query for "latest news on AI", the number of results to fetch (num: 10), and the starting index (start: 0).

  • Additionally, it specifies headers, including an Authorization key (which needs to be replaced with a valid API key) and a Content-Type set to application/json.

  • The request is then sent using requests.get, but there is a mistake in the method call—the "GET" string should not be included, as requests.get(url, params=params, headers=headers) is the correct syntax.

  • Finally, the script prints the response content, displaying the retrieved news data.

    import requests

    url = "https://apis.datura.ai/web"

    params =  {
      "query": "latest news on AI",
      "num": 10,
      "start": 0
    }
    headers = {
        "Authorization": "<your-api-key>",
        "Content-Type": "application/json"
    }

    response = requests.get("GET", url, params=params, headers=headers)

    print(response.text)
    const fetch = require("node-fetch");

    const url = "https://apis.datura.ai/web";
    const params = new URLSearchParams({
        query: "latest news on AI",
        num: 10,
        start: 0
    });

    const headers = {
        "Authorization": "<your-api-key>",
        "Content-Type": "application/json"
    };

    fetch(`${url}?${params.toString()}`, {
        method: "GET",
        headers: headers
    })
    .then(response => response.text())
    .then(data => console.log(data))
    .catch(error => console.error("Error:", error));

    const axios = require("axios");

    const url = "https://apis.datura.ai/web";

    const params = {
        query: "latest news on AI",
        num: 10,
        start: 0
    };

    const headers = {
        Authorization: "<your-api-key>",
        "Content-Type": "application/json"
    };

    axios.get(url, { params, headers })
        .then(response => console.log(response.data))
        .catch(error => console.error("Error:", error.response?.data || error.message));
    <?php

    $url = "https://apis.datura.ai/web";
    $params = http_build_query([
        "query" => "latest news on AI",
        "num" => 10,
        "start" => 0
    ]);

    $headers = [
        "Authorization: <your-api-key>",
        "Content-Type: application/json"
    ];

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "$url?$params");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

    $response = curl_exec($ch);
    curl_close($ch);

    echo $response;
    ?>
    import Foundation

    let urlString = "https://apis.datura.ai/web"
    var components = URLComponents(string: urlString)
    components?.queryItems = [
        URLQueryItem(name: "query", value: "latest news on AI"),
        URLQueryItem(name: "num", value: "10"),
        URLQueryItem(name: "start", value: "0")
    ]

    guard let url = components?.url else { return }

    var request = URLRequest(url: url)
    request.httpMethod = "GET"
    request.setValue("<your-api-key>", forHTTPHeaderField: "Authorization")
    request.setValue("application/json", forHTTPHeaderField: "Content-Type")

    let task = URLSession.shared.dataTask(with: request) { data, response, error in
        if let error = error {
            print("Error: \(error)")
            return
        }
        if let data = data, let responseString = String(data: data, encoding: .utf8) {
            print("Response: \(responseString)")
        }
    }

    task.resume()

Parameters

Required

  • url: The endpoint for the Basic Web Search API.

  • payload/query

    • query: The search query string, e.g., 'latest news on AI'.

Optional

  • num: Count of results to get, e.g., 10
  • start: How many results to skip (used for pagination with num), e.g., 0

Response Sample

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

    {
        "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
            }
        ]
    }

Test API

To experiment with the Basic Web Search API and see it in action, visit the Basic Web Search API.