Basic Web Search
Web search API allows you to search the web for information similar to a search engine. (Coming Soon)
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.
Using the Basic Web Search API
The following examples demonstrate how to interact with the Basic Web Search API using both multiple coding platform.
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.
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., 10start
: 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 retrieve as JSON. Each coding language has its own way of retrieving data from the below JSON.
Test API
To experiment with the Basic Web Search API and see it in action, visit the Basic Web Search API.