logo
theme
Custom Search
FREEMIUM
By contextualwebsearch
Updated 5 months ago
Custom Search Overview
Create a web-scale custom search engine for any collections of domains and easily integrate them in your products. You can configure your search engine to search web pages, news and images.
provider
rating
add first rating
Followers on API
Follow this API
resourcesProvider WebsiteTerms of Service
More Details

Contextual Web (contextualwebsearch.com)

Custom Search - Powerful search for your domains

ContextualWeb enables you to create a large scale internet search engine for any collections of domains and to easily integrate them in your products. You can configure your search engine to search web pages, news and images.

To set up your custom search engine go to:

https://cse.contextualweb.io

Get programatic access to your custom search engine:

Web Search API
News API
Image API

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
searchEngineId = XXXX #the id of the custom search engine 

response=requests.get("https://custom-search.p.rapidapi.com/api/search/CustomWebSearchAPIV2?q={}&pageNumber={}&searchEngineId={}".format(q, pageNumber, searchEngineId),
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
searchEngineId = "XXXX"; #the id of the custom search engine 


u.get("https://custom-search.p.rapidapi.com/api/search/CustomWebSearchAPIV2?q=" + q + "&pageNumber=" + pageNumber + "&searchEngineId=" + searchEngineId)
    .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
searchEngineId = "XXXX" #the id of the custom search engine 

response = Unirest.get "https://custom-search.p.rapidapi.com/api/search/CustomWebSearchAPIV2?q=#{q}&pageNumber=#{pageNumber}&searchEngineId=#{searchEngineId}",
  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
    string searchEngineId = "XXXX"; #the id of the custom search engine 

    //Perform the web request and get the response
    var response = Unirest.get(string.Format("https://custom-search.p.rapidapi.com/api/search/CustomWebSearchAPIV2?q={0}&pageNumber={1}&searchEngineId={2}, q, pageNumber, searchEngineId))
    .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
searchEngineId = "XXXX" #the id of the custom search engine 

response=requests.get("https://custom-search.p.rapidapi.com/api/search/CustomNewsSearchAPIV2?q={}&pageNumber={}&searchEngineId={}".format(q, pageNumber, searchEngineId),
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
searchEngineId = "XXXX" #the id of the custom search engine 

u.get("https://custom-search.p.rapidapi.com/api/search/CustomNewsSearchAPIV2?q=" + q + "&pageNumber=" + pageNumber + "&searchEngineId=" + searchEngineId)
    .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
searchEngineId = "XXXX"; #the id of the custom search engine 

response = Unirest.get "https://custom-search.p.rapidapi.com/api/search/CustomNewsSearchAPIV2?q=#{q}&pageNumber=#{pageNumber}&searchEngineId=#{searchEngineId}",
  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
    string searchEngineId = "XXXX"; #the id of the custom search engine 

    //Perform the web request and get the response
    var response = Unirest.get(string.Format("https://custom-search.p.rapidapi.com/api/search/CustomNewsSearchAPIV2?q={0}&pageNumber={1}&searchEngineId={2}", 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
searchEngineId = "XXXX"; #the id of the custom search engine 

response=requests.get("https://custom-search.p.rapidapi.com/api/search/CustomImageSearchAPIV2?q={}&pageNumber={}&searchEngineId={}".format(q, pageNumber, searchEngineId),
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
searchEngineId = "XXXX"; #the id of the custom search engine 

u.get("https://custom-search.p.rapidapi.com/api/search/CustomImageSearchAPIV2?q=" + q + "&pageNumber=" + pageNumber + "&searchEngineId=" + searchEngineId)
    .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
searchEngineId = "XXXX"; #the id of the custom search engine 

response = Unirest.get "https://custom-search.p.rapidapi.com/api/search/CustomImageSearchAPIV2?q=#{q}&pageNumber=#{pageNumber}&searchEngineId=#{searchEngineId}",
  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
    string searchEngineId = "XXXX"; #the id of the custom search engine 

    //Perform the web request and get the response
    var response = Unirest.get(string.Format("https://custom-search.p.rapidapi.com/api/search/CustomImageSearchAPIV2?q={0}&pageNumber={1}&searchEngineId={2}", q, pageNumber, searchEngineId))
    .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));
    }
}
Have a question about this API?Ask the API Provider.
More by contextualwebsearch
9.8
3129ms
97%
Developers who viewed Custom Search also viewed
9.6
422ms
96%
9.8
3129ms
97%
9.8
373ms
99%
9.6
162ms
100%

Install SDK for (Node.js)Unirest

OAuth2 Authentication
Client ID
Client Secret
OAuth2 Authentication