REST API to Google Search: Search, Feed, and Translation APIs to non Ajax usage

The Google AJAX Search API lets you put Google Search in your web pages with JavaScript. You can embed a simple, dynamic search box and display search results in your own web pages or use the results in innovative, programmatic ways. See the examples below for inspiration. The Google Ajax API team has a new release that […]

The Google AJAX Search API lets you put Google Search in your web pages with JavaScript. You can embed a simple, dynamic search box and display search results in your own web pages or use the results in innovative, programmatic ways. See the examples below for inspiration.

The Google Ajax API team has a new release that enables you to access AJAX Search APIs from any web application, Flash or the server side. If you know how to make an http request, and how to process a JSON response, you are in business. The other two Google AJAX APIs for feeds and translations were updated for non-AJAX use, as well.

“For Flash developers, and those developers that have a need to access the AJAX Search API from other Non-Javascript environments, the API exposes a simple RESTful interface. In all cases, the method supported is GET and the response format is a JSON encoded result set with embedded status codes.”

Here's a simple example for web search:
http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=Earth%20Day

There are some differences between the old SOAP API and the REST one.

Pros:

  • the new API doesn't require a key
  • there's no limitation for the number of queries
  • it's much easier to use
  • you can use the REST API for web search, but also for image search, news search, video search, local search, blog search and book search.

Cons:

  • you need to send "a valid and accurate http referer header".
  • you can only get up to 8 results in a single call and you can't go beyond the first 32 results
  • the terms of use are pretty restrictive: for example, you need to attribute the results to Google and you are not allowed to change the order of search results.

Check out the relevant documentation for:

Google, JavaScript, Ajax, API, Search, Feed, JSON, REST, Language Translation