Google Custom Search .NET API (Miscellaneous)

What is Google custom search?

Google custom search is a powerful, yet simple search engine. It allows the searching and presentation of search results on you website with the minimum of fuss.

What is the Google custom search API?

The Google Custom Search API lets you develop websites and programs to retrieve and display search results from Google Custom Search programmatically. With this API, you can use make requests to get either web search or image search results.

What is the Google custom search .NET API?

The power of Google custom search is now at your fingertips using a well built and powerful .NET API. Take advantage of the features of Google custom search using simple .NET calls. The component is written in C# and brings the power of custom search to all your .NET applications including:

  • Console
  • Windows Forms
  • WPF
  • ASP.NET
  • ASP.NET MVC
  • Windows Services
  • Web Services (XML/WCF)
  • Silverlight
  • All .NET applications

What features are available when searching?

The search features available within the component are:

  • Specify the search terms
  • Specify page
  • Turns on/off the translation between zh-CN and zh-TW
  • Country restriction
  • Specify linked custom search engine or use custom search engine ID
  • Specify all search results from a time period
  • Identify a phrase that all documents in the search results must contain
  • Identify a word or phrase that should not appear in any documents in the search results
  • Returns images of a specified type
  • Controls turning on or off the duplicate content
  • Specify geolocation of end user
  • The local Google domain to use to perform the search
  • Sets the user interface language
  • Allows the addition of extra query terms
  • Specify image colour
  • Return images of a specific dominant colour
  • Return images of a specified size
  • Return images of a specific type
  • Specify that all search results should contain a link to a particular URL
  • Specify the language restriction for the search results
  • Provide additional search terms to check for in a document, where each document in the search results must contain at least one of the additional search terms
  • Specify that all search results should be pages that are related to the specified URL
  • Specify filter based on licensing
  • Search safety level
  • Specify the search type (web pages or images)
  • Specify all search results should be pages from a given site
  • Controls whether to include or exclude results from a site

What do you get with your purchase?

  1. Fully documented solution (source code)
  2. 1 x ASP.NET MVC demo application
  3. 1 x ASP.NET WebForm demo application
  4. 1 x Console demo application
  5. Compiled assemblies ready to use in your application
  6. Full documentation on how to use the component

Here is a simple example of how to take advantage of our Fluent & Standard API to perform and search using a search engine defined from your Google account. Learn more about creating search engines and getting API access to the Google services.

Fluent API

var authToken = new ApiKeyAuth([...Your GoogleApiKey...]);
var searchEngine = new SearchEngineIdBased([...Your SearchEngineId...]);

// Use fluent API
var searchResults = new GoogleFluentCustomSearch()
    .SetSearchTerms("codecanyon")
    .SetPage((new Page())
                 .SetPageNumber(1)
                 .SetPageSize(10))
    .SetAuthenticator(authToken)
    .SetSearchEngine(searchEngine)
    .Search();

Standard API

var authToken = new ApiKeyAuth([...Your GoogleApiKey...]);
var searchEngine = new SearchEngineIdBased([...Your SearchEngineId...]);

// Use standard API
var standardSearch = new GoogleCustomSearch(authToken, searchEngine);
var query = new SearchQuery()
    {
        SearchTerms = searchTerms,
        Page = new Page(pageNumber, 5)
    };
searchResults = standardSearch.Search(query);

Fluent API & Asynchronous search

// Use fluent API & Asynchronous search
void Search() 
{
    new GoogleFluentCustomSearch()
        .SetSearchTerms(searchTerms)
        .SetPage((new Page())
                     .SetPageNumber(pageNumber)
                     .SetPageSize(5))
        .SetAuthenticator(authToken)
        .SetSearchEngine(searchEngine)
        .OnSearchComplete(ProcessSearchResults)
        .SearchAsync();
}

void ProcessSearchResults(SearchResult searchResults)
{
    ...
}

Search results

The search results offer a comprehensive object from the data Google offers and contains the following parts:

  • Search results
  • Current, Next and Previous page search queries
  • Search spelling – Encapsulates a corrected query
  • Search information – Encapsulates all information about the search
  • Search URL – The OpenSearch URL element that defines the template for the API.
  • Search kind – Unique identifier for the type of current object
  • Search context – Metadata about the particular search engine that was used for performing the search query

What else do you get from this component?

  • Fully commented
  • Excellent memory management
  • Optimised for performance
  • Supports ThreadPool and non-ThreadPool asynchronous/parallel searches. Necessary for ASP.NET applications to avoid the dreaded “service unavailable” when processing high volumes
  • Strong name signed – Allows referencing in other application that are strong named signed & also can be installed to the Global Assembly Cache (GAC)

This component is built using the .NET 3.5 Framework which means in can be used in all .NET applications that are using the 3.5 framework or later. This includes .NET 3.5, 4.0, & 4.5, +.

Download Google Custom Search .NET API (Miscellaneous)

Leave a Reply

Your email address will not be published. Required fields are marked *