Web Search

FREEMIUM
By contextualwebsearch
Updated 4 months ago
Data
9.6/10
Popularity Score
2363ms
Latency
99%
Success Rate

Web Search API Overview

Web Search API. News API. Image API. Billions of webpages, images and news with a single API call. Build your app for free. Get 10,000 free API requests per month. Visit us at: contextualwebsearch.com

Contact API Provider
star-blueRate

Contextual Web (contextualwebsearch.com)

Web Search API
News API
Image API

Billions of webpages, images and news with a single API call.
The API returns a list of relevant results from a search query which include images, news and related searches.

Features

Support

24/7 Email Support: [email protected]

Working Code Examples: Sending a request and parsing the response

1. Web Search API

Python 3.x

import requests #install from: http://docs.python-requests.org/en/master/

#Replace the following string value with your valid X-RapidAPI-Key.
Your_X_RapidAPI_Key = "XXXXXXXXXXXXXXXXXXX";

#The query parameters: (update according to your search query)
q = "Taylor%20Swift" #the search query
pageNumber = 1 #the number of requested page
pageSize = 10 #the size of a page
autoCorrect = True #autoCorrectspelling
safeSearch = False #filter results for adult content

response=requests.get("https://contextualwebsearch-websearch-v1.p.rapidapi.com/api/Search/WebSearchAPI?q={}&pageNumber={}&pageSize={}&autocorrect={}&safeSearch={}".format(q, pageNumber, pageSize, autoCorrect,safeSearch),
headers={
"X-RapidAPI-Key": Your_X_RapidAPI_Key
}
).json()

#Get the numer of items returned
totalCount = response["totalCount"];

#Get the list of most frequent searches related to the input search query
relatedSearch = response["relatedSearch"]

#Go over each resulting item
for webPage in response["value"]:

#Get the web page metadata
    url = webPage["url"]
    title = webPage["title"]
    description = webPage["description"]
    keywords = webPage["keywords"]
    provider = webPage["provider"]["name"]
    datePublished = webPage["datePublished"]

    #Get the web page image (if exists)
    imageUrl = webPage["image"]["url"]
    imageHeight = webPage["image"]["height"]
    imageWidth = webPage["image"]["width"]

    thumbnail = webPage["image"]["thumbnail"]
    thumbnailHeight = webPage["image"]["thumbnailHeight"]
    thumbnailWidth = webPage["image"]["thumbnailWidth"]

    #An example: Output the webpage url, title and published date:
    print("Url: %s. Title: %s. Published Date:%s." % (url, title, datePublished))

Node.js

const u = require("unirest"); //intsall from: http://unirest.io/nodejs.html

//Replace the following string value with your valid X-RapidAPI-Key.
Your_X_RapidAPI_Key = "XXXXXXXXXXXXXXXXXXXX";

//The query parameters: (update according to your search query)
q = "Taylor%20Swift"; #the search query
pageNumber = 1; #the number of requested page
pageSize = 10; #the size of a page
autoCorrect = true; #autoCorrectspelling
safeSearch = false; #filter results for adult content

u.get("https://contextualwebsearch-websearch-v1.p.rapidapi.com/api/Search/WebSearchAPI?q=" + q + "&pageNumber=" + pageNumber + "&pageSize=" + pageSize+ "&autoCorrect=" + autoCorrect+ "&safeSearch=" + safeSearch)
    .header("X-RapidAPI-Key", Your_X_RapidAPI_Key)
    .end(function(result) {

        console.log("HTTP status code: " + result.status);

        //Get the numer of items returned
        totalCount = result.body["totalCount"];

        //Get the list of most frequent searches related to the input search query
        relatedelatedSearch = result.body["relatedSearch"]

        for (i = 0; i < result.body["value"].length; i++) {

            webPage = result.body["value"][i];

            //Get the web page metadata
            url = webPage["url"];
            title = webPage["title"];
            description = webPage["description"];
            keywords = webPage["keywords"];
            provider = webPage["provider"]["name"];
            datePublished = webPage["datePublished"];

            //Get the web page image (if exists)
            imageUrl = webPage["image"]["url"];
            imageHeight = webPage["image"]["height"];
            imageWidth = webPage["image"]["width"];

            thumbnail = webPage["image"]["thumbnail"];
            thumbnailHeight = webPage["image"]["thumbnailHeight"];
            thumbnailWidth = webPage["image"]["thumbnailWidth"];

            //An example: Output the webpage url, title and published date:
            console.log("Url: %s. Title: %s. Published Date:%s.\n", url, title, datePublished);
        }

    });

Ruby

require "unirest" # install from: http://unirest.io/ruby.html

#Replace the following string value with your valid X-RapidAPI-Key.
Your_X_RapidAPI_Key = "XXXXXXXXXXXXXXXXXXX"

#The query parameters: (update according to your search query)
q = "Taylor%20Swift"; #the search query
pageNumber = 1 #the number of requested page
pageSize = 10 #the size of a page
autoCorrect = true #autoCorrectspelling
safeSearch = false #filter results for adult content

response = Unirest.get "https://contextualwebsearch-websearch-v1.p.rapidapi.com/api/Search/WebSearchAPI?q=#{q}&pageNumber=#{pageNumber}&pageSize=#{pageSize}&autoCorrect=#{autoCorrect}&safeSearch=#{safeSearch}",
  headers:{
    "X-RapidAPI-Key" => Your_X_RapidAPI_Key
  }

#Get the numer of items returned
totalCount = response.body["totalCount"]

#Get the list of most frequent searches related to the input search query
relatedSearch = response.body["relatedSearch"]

#Go over each resulting item
response.body["value"].each do |webPage|

    #Get the web page metadata  
    url = webPage["url"]
    title = webPage["title"]
    description = webPage["description"]
    keywords = webPage["keywords"]
    provider = webPage["provider"]["name"]
    datePublished = webPage["datePublished"]

    #Get the web page image (if exists)
    imageUrl = webPage["image"]["url"]
    imageHeight = webPage["image"]["height"]
    imageWidth = webPage["image"]["width"]

    thumbnail = webPage["image"]["thumbnail"]
    thumbnailHeight = webPage["image"]["thumbnailHeight"]
    thumbnailWidth = webPage["image"]["thumbnailWidth"]

    #An example: Output the webpage url, title and published date:
    puts "Url: #{url}. Title: #{title}. Published Date: #{datePublished}"

end

c# (.Net)

/// <summary>
/// Performs a Web search and return the results as a SearchResult.
/// Required Package: Unirest-API (https://www.nuget.org/packages/Unirest-API/)
/// </summary>

public static void Test()
{
    //Replace the following string value with your valid X-RapidAPI-Key.
    string Your_X_RapidAPI_Key = "xxxxxxxxxxxxxxxxxxxxx";

    //The query parameters: (update according to your search query)
    string q = "Taylor%20Swift"; //the search query
    int pageNumber = 1; //the number of requested page
    int pageSize = 10; //the size of a page
    bool autoCorrect = true; //autoCorrectspelling
    bool safeSearch = false; //filter results for adult content

    //Perform the web request and get the response
    var response = Unirest.get(string.Format("https://contextualwebsearch-websearch-v1.p.rapidapi.com/api/Search/WebSearchAPI?q={0}&pageNumber={1}&pageSize={2}&autoCorrect={3}&safeSearch={4}", q, pageNumber, pageSize, autoCorrect, safeSearch))
    .header("X-RapidAPI-Key", Your_X_RapidAPI_Key)
    .asJson<string>();

    //Get the ResponseBody as a JSON
    dynamic jsonBody = JsonConvert.DeserializeObject(response.Body);

    //Parse the results

    //Get the numer of items returned
    int totalCount = (int)jsonBody["totalCount"];

    //Get the list of most frequent searches related to the input search query
    List<string> relatedSearch = JsonConvert.DeserializeObject<List<string>>(jsonBody["relatedSearch"].ToString());

    //Go over each resulting item
    foreach (var webPage in jsonBody["value"])
    {
        //Get the web page metadata
        string url = webPage["url"].ToString();
        string title = webPage["title"].ToString();
        string description = webPage["description"].ToString();
        string keywords = webPage["keywords"].ToString();
        string provider = webPage["provider"]["name"].ToString();
        DateTime datePublished = DateTime.Parse(webPage["datePublished"].ToString());

        //Get the web page image (if exists)
        string imageUrl = webPage["image"]["url"].ToString(); 
        int imageHeight = (int)webPage["image"]["height"]; 
        int imageWidth = (int)webPage["image"]["width"]; 

        //Get the web page image thumbail (if exists)
        string thumbnail = webPage["image"]["thumbnail"].ToString(); 
        int thumbnailHeight = (int)webPage["image"]["thumbnailHeight"]; 
        int thumbnailidth = (int)webPage["image"]["thumbnailWidth"]; 

        //An example: Output the webpage url, title and published date:
        Console.WriteLine(string.Format("Url: {0}. Title: {1}. Published Date:{2}.",
        url,
        title,
        datePublished));
    }
}

2. News Search API

Python 3.x

import requests #install from: http://docs.python-requests.org/en/master/

#Replace the following string value with your valid X-RapidAPI-Key.
Your_X_RapidAPI_Key = "XXXXXXXXXXXXXXXXXXX";

#The query parameters: (update according to your search query)
q = "Taylor%20Swift" #the search query
pageNumber = 1 #the number of requested page
pageSize = 10 #the size of a page
autoCorrect = True #autoCorrectspelling
safeSearch = False #filter results for adult content

response=requests.get("https://contextualwebsearch-websearch-v1.p.rapidapi.com/api/Search/NewsSearchAPI?q={}&pageNumber={}&pageSize={}&autocorrect={}&safeSearch={}".format(q, pageNumber, pageSize, autoCorrect,safeSearch),
headers={
"X-RapidAPI-Key": Your_X_RapidAPI_Key
}
).json()

#Get the numer of items returned
totalCount = response["totalCount"];

#Get the list of most frequent searches related to the input search query
relatedSearch = response["relatedSearch"]

#Go over each resulting item
for webPage in response["value"]:

#Get the web page metadata
    url = webPage["url"]
    title = webPage["title"]
    description = webPage["description"]
    keywords = webPage["keywords"]
    provider = webPage["provider"]["name"]
    datePublished = webPage["datePublished"]

    #Get the web page image (if exists)
    imageUrl = webPage["image"]["url"]
    imageHeight = webPage["image"]["height"]
    imageWidth = webPage["image"]["width"]

    thumbnail = webPage["image"]["thumbnail"]
    thumbnailHeight = webPage["image"]["thumbnailHeight"]
    thumbnailWidth = webPage["image"]["thumbnailWidth"]

    #An example: Output the webpage url, title and published date:
    print("Url: %s. Title: %s. Published Date:%s." % (url, title, datePublished))

Node.js

const u = require("unirest"); //intsall from: http://unirest.io/nodejs.html

//Replace the following string value with your valid X-RapidAPI-Key.

Your_X_RapidAPI_Key = "XXXXXXXXXXXXXXXXXXXX";

//The query parameters: (update according to your search query)
q = "Taylor%20Swift"; #the search query
pageNumber = 1; #the number of requested page
pageSize = 10; #the size of a page
autoCorrect = true; #autoCorrectspelling
safeSearch = false; #filter results for adult content

u.get("https://contextualwebsearch-websearch-v1.p.rapidapi.com/api/Search/NewsSearchAPI?q=" + q + "&pageNumber=" + pageNumber + "&pageSize=" + pageSize+ "&autoCorrect=" + autoCorrect+ "&safeSearch=" + safeSearch)
    .header("X-RapidAPI-Key", Your_X_RapidAPI_Key)
    .end(function(result) {

        console.log("HTTP status code: " + result.status);

        //Get the numer of items returned
        totalCount = result.body["totalCount"];

        //Get the list of most frequent searches related to the input search query
        relatedelatedSearch = result.body["relatedSearch"]

        for (i = 0; i < result.body["value"].length; i++) {

            webPage = result.body["value"][i];

            //Get the web page metadata
            url = webPage["url"];
            title = webPage["title"];
            description = webPage["description"];
            keywords = webPage["keywords"];
            provider = webPage["provider"]["name"];
            datePublished = webPage["datePublished"];

            //Get the web page image (if exists)
            imageUrl = webPage["image"]["url"];
            imageHeight = webPage["image"]["height"];
            imageWidth = webPage["image"]["width"];

            thumbnail = webPage["image"]["thumbnail"];
            thumbnailHeight = webPage["image"]["thumbnailHeight"];
            thumbnailWidth = webPage["image"]["thumbnailWidth"];

            //An example: Output the webpage url, title and published date:
            console.log("Url: %s. Title: %s. Published Date:%s.\n", url, title, datePublished);
        }

    });

Ruby

require "unirest" # install from: http://unirest.io/ruby.html

#Replace the following string value with your valid X-RapidAPI-Key.
Your_X_RapidAPI_Key = "XXXXXXXXXXXXXXXXXXX"

#The query parameters: (update according to your search query)
q = "Taylor%20Swift"; #the search query
pageNumber = 1 #the number of requested page
pageSize = 10 #the size of a page
autoCorrect = true #autoCorrectspelling
safeSearch = false #filter results for adult content

response = Unirest.get "https://contextualwebsearch-websearch-v1.p.rapidapi.com/api/Search/NewsSearchAPI?q=#{q}&pageNumber=#{pageNumber}&pageSize=#{pageSize}&autoCorrect=#{autoCorrect}&safeSearch=#{safeSearch}",
  headers:{
    "X-RapidAPI-Key" => Your_X_RapidAPI_Key
  }

#Get the numer of items returned
totalCount = response.body["totalCount"]

#Get the list of most frequent searches related to the input search query
relatedSearch = response.body["relatedSearch"]

#Go over each resulting item
response.body["value"].each do |webPage|

    #Get the web page metadata  
    url = webPage["url"]
    title = webPage["title"]
    description = webPage["description"]
    keywords = webPage["keywords"]
    provider = webPage["provider"]["name"]
    datePublished = webPage["datePublished"]

    #Get the web page image (if exists)
    imageUrl = webPage["image"]["url"]
    imageHeight = webPage["image"]["height"]
    imageWidth = webPage["image"]["width"]

    thumbnail = webPage["image"]["thumbnail"]
    thumbnailHeight = webPage["image"]["thumbnailHeight"]
    thumbnailWidth = webPage["image"]["thumbnailWidth"]

    #An example: Output the webpage url, title and published date:
    puts "Url: #{url}. Title: #{title}. Published Date: #{datePublished}"

end

c# (.Net)

/// <summary>
/// Performs a Web search and return the results as a SearchResult.
/// Required Package: Unirest-API (https://www.nuget.org/packages/Unirest-API/)
/// </summary>

public static void Test()
{
    //Replace the following string value with your valid X-RapidAPI-Key.
    string Your_X_RapidAPI_Key = "xxxxxxxxxxxxxxxxxxxxx";

    //The query parameters: (update according to your search query)
    string q = "Taylor%20Swift"; //the search query
    int pageNumber = 1; //the number of requested page
    int pageSize = 10; //the size of a page
    bool autoCorrect = true; //autoCorrectspelling
    bool safeSearch = false; //filter results for adult content

    //Perform the web request and get the response
    var response = Unirest.get(string.Format("https://contextualwebsearch-websearch-v1.p.rapidapi.com/api/Search/NewsSearchAPI?q={0}&pageNumber={1}&pageSize={2}&autoCorrect={3}&safeSearch={4}", q, pageNumber, pageSize, autoCorrect, safeSearch))
    .header("X-RapidAPI-Key", Your_X_RapidAPI_Key)
    .asJson<string>();

    //Get the ResponseBody as a JSON
    dynamic jsonBody = JsonConvert.DeserializeObject(response.Body);

    //Parse the results

    //Get the numer of items returned
    int totalCount = (int)jsonBody["totalCount"];

    //Get the list of most frequent searches related to the input search query
    List<string> relatedSearch = JsonConvert.DeserializeObject<List<string>>(jsonBody["relatedSearch"].ToString());

    //Go over each resulting item
    foreach (var webPage in jsonBody["value"])
    {
        //Get the web page metadata
        string url = webPage["url"].ToString();
        string title = webPage["title"].ToString();
        string description = webPage["description"].ToString();
        string keywords = webPage["keywords"].ToString();
        string provider = webPage["provider"]["name"].ToString();
        DateTime datePublished = DateTime.Parse(webPage["datePublished"].ToString());

        //Get the web page image (if exists)
        string imageUrl = webPage["image"]["url"].ToString(); 
        int imageHeight = (int)webPage["image"]["height"]; 
        int imageWidth = (int)webPage["image"]["width"]; 

        //Get the web page image thumbail (if exists)
        string thumbnail = webPage["image"]["thumbnail"].ToString(); 
        int thumbnailHeight = (int)webPage["image"]["thumbnailHeight"]; 
        int thumbnailidth = (int)webPage["image"]["thumbnailWidth"]; 

        //An example: Output the webpage url, title and published date:
        Console.WriteLine(string.Format("Url: {0}. Title: {1}. Published Date:{2}.",
        url,
        title,
        datePublished));
    }
}

3. Image Search API

Python 3.x

import requests #install from: http://docs.python-requests.org/en/master/

#Replace the following string value with your valid X-RapidAPI-Key.
Your_X_RapidAPI_Key = "XXXXXXXXXXXXXXXXXXX";

#The query parameters: (update according to your search query)
q = "Taylor%20Swift" #the search query
pageNumber = 1 #the number of requested page
pageSize = 10 #the size of a page
autoCorrect = True #autoCorrectspelling
safeSearch = False #filter results for adult content

response=requests.get("https://contextualwebsearch-websearch-v1.p.rapidapi.com/api/Search/ImageSearchAPI?q={}&pageNumber={}&pageSize={}&autocorrect={}&safeSearch={}".format(q, pageNumber, pageSize, autoCorrect,safeSearch),
headers={
"X-RapidAPI-Key": Your_X_RapidAPI_Key
}
).json()

#Get the numer of items returned
totalCount = response["totalCount"];

#Go over each resulting item
for image in response["value"]:

    # Get the image
    imageUrl = webPage["url"]
    imageHeight = webPage["height"]
    imageWidth = webPage["width"]

    # Get the image thumbail
    thumbnail = webPage["thumbnail"]
    thumbnailHeight = webPage["thumbnailHeight"]
    thumbnailWidth = webPage["thumbnailWidth"]

    #An example: Output the webpage url, title and published date:
    print("imageUrl: %s. imageHeight: %s. imageWidth: %s." % (imageUrl, imageHeight, imageWidth))

Node.js

const u = require("unirest"); //intsall from: http://unirest.io/nodejs.html

//Replace the following string value with your valid X-RapidAPI-Key.

Your_X_RapidAPI_Key = "XXXXXXXXXXXXXXXXXXXX";

//The query parameters: (update according to your search query)
q = "Taylor%20Swift"; #the search query
pageNumber = 1; #the number of requested page
pageSize = 10; #the size of a page
autoCorrect = true; #autoCorrectspelling
safeSearch = false; #filter results for adult content

u.get("https://contextualwebsearch-websearch-v1.p.rapidapi.com/api/Search/ImageSearchAPI?q=" + q + "&pageNumber=" + pageNumber + "&pageSize=" + pageSize+ "&autoCorrect=" + autoCorrect+ "&safeSearch=" + safeSearch)
    .header("X-RapidAPI-Key", Your_X_RapidAPI_Key)
    .end(function(result) {

        console.log("HTTP status code: " + result.status);

        //Get the numer of items returned
        totalCount = result.body["totalCount"];

        for (i = 0; i < result.body["value"].length; i++) {

            image = result.body["value"][i];

            //Get the image
            imageUrl = image["url"];
            imageHeight = image["height"];
            imageWidth = image["width"];

            //Get the image thumbail
            thumbnail = image["thumbnail"];
            thumbnailHeight = image["thumbnailHeight"];
            thumbnailWidth = image["thumbnailWidth"];

            //An example: Output the webpage url, title and published date:
            console.log("imageUrl: %s. imageHeight: %s. imageWidth: %s.\n", imageUrl, imageHeight, imageWidth);
        }

    });

Ruby

require "unirest" # install from: http://unirest.io/ruby.html

#Replace the following string value with your valid X-RapidAPI-Key.
Your_X_RapidAPI_Key = "XXXXXXXXXXXXXXXXXXX"

#The query parameters: (update according to your search query)
q = "Taylor%20Swift"; #the search query
pageNumber = 1 #the number of requested page
pageSize = 10 #the size of a page
autoCorrect = true #autoCorrectspelling
safeSearch = false #filter results for adult content

response = Unirest.get "https://contextualwebsearch-websearch-v1.p.rapidapi.com/api/Search/ImageSearchAPI?q=#{q}&pageNumber=#{pageNumber}&pageSize=#{pageSize}&autoCorrect=#{autoCorrect}&safeSearch=#{safeSearch}",
  headers:{
    "X-RapidAPI-Key" => Your_X_RapidAPI_Key
  }

#Get the numer of items returned
totalCount = response.body["totalCount"]

#Go over each resulting item
response.body["value"].each do |image|

    #Get the image
    imageUrl = image["url"]
    imageHeight = image["height"]
    imageWidth = image["width"]

    #Get the image thumbail
    thumbnail = image["thumbnail"]
    thumbnailHeight = image["thumbnailHeight"]
    thumbnailWidth = image["thumbnailWidth"]

    #An example: Output the webpage url, title and published date:
    puts "imageUrl: #{imageUrl}. imageHeight: #{imageHeight}. imageWidth: #{imageWidth}"

end

c# (.Net)

public static void Test()
{
    //Replace the following string value with your valid X-RapidAPI-Key.
    string Your_X_RapidAPI_Key = "xxxxxxxxxxxxxxxxxxxxx";

    //The query parameters: (update according to your search query)
    string q = "Taylor%20Swift"; //the search query
    int pageNumber = 1; //the number of requested page
    int pageSize = 10; //the size of a page
    bool autoCorrect = true; //autoCorrectspelling
    bool safeSearch = false; //filter results for adult content

    //Perform the web request and get the response
    var response = Unirest.get(string.Format("https://contextualwebsearch-websearch-v1.p.rapidapi.com/api/Search/ImageSearchAPI?q={0}&pageNumber={1}&pageSize={2}&autoCorrect={3}&safeSearch={4}", q, pageNumber, pageSize, autoCorrect, safeSearch))
    .header("X-RapidAPI-Key", Your_X_RapidAPI_Key)
    .asJson<string>();

     //Get the ResponseBody as a JSON
    dynamic jsonBody = JsonConvert.DeserializeObject(response.Body);

    //Get the number of items returned
    int totalCount = (int)jsonBody["totalCount"];

    //Go over each resulting item
    foreach (var image in jsonBody["value"])
    {
        //Get the image
        string imageUrl = image["url"].ToString();
        int imageHeight = (int)image["height"];
        int imageWidth = (int)image["width"];

        //Get the image thumbail
        string thumbnail = image["thumbnail"].ToString();
        int thumbnailHeight = (int)image["thumbnailHeight"];
        int thumbnailWidth = (int)image["thumbnailWidth"];

        Console.WriteLine(string.Format("imageUrl: {0}. imageHeight: {1}. imageWidth: {2}",
        imageUrl,
        imageHeight,
        imageWidth));
    }
}

Install SDK for NodeJS

Installing

To utilize unirest for node.js install the the npm module:

$ npm install unirest

After installing the npm package you can now start simplifying requests like so:

var unirest = require('unirest');

Creating Request

unirest.get("https://contextualwebsearch-websearch-v1.p.rapidapi.com/api/spelling/AutoComplete?text=do")
.header("X-RapidAPI-Host", "contextualwebsearch-websearch-v1.p.rapidapi.com")
.header("X-RapidAPI-Key", "SIGN-UP-FOR-KEY")
.end(function (result) {
  console.log(result.status, result.headers, result.body);
});
OAuth2 Authentication
Client ID
Client Secret
OAuth2 Authentication