Tuesday, April 22nd, 2008

Google offers Search, Feed, and Translation APIs to Non Ajax Usage

Category: Google, JavaScript, JSON, Library

The Google Ajax API team has been offering great services that you can use from JavaScript in the browser. I have talked about some of them on Ajaxian before (Feed API, Feed Discovery API, and the recent Language API) but now we have a great new release that enables you to access these APIs from Flash or the server side.

In fact, as long as your program can speak HTTP, you can have access to the services.

For example, you could now call this an REST API to Google Search.

To see it in action, point to something like http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=Ajaxian and you will see the JSON output that is documented.

There are terms of use that you should abide by, and some other comments:

An area to pay special attention to relates to correctly identifying
yourself in your requests. Applications MUST always include a valid and accurate http referer header in their requests. In addition, we ask, but do not require, that each request contains a valid API Key. By providing a key, your application provides us with a secondary identification mechanism that is useful should we need to contact you in order to correct any problems.

Check out the updated documentation for more details on each API:

Including code snippets. For example, here is how you would access the search results in ActionScript:


  1. var service:HTTPService = new HTTPService();
  2. service.url = 'http://ajax.googleapis.com/ajax/services/search/web';
  3. service.request.v = '1.0';
  4. service.request.q = 'Paris Hilton';
  5. service.resultFormat = 'text';
  6. service.addEventListener(ResultEvent.RESULT, onServerResponse);
  7. service.send();
  9. private function onServerResponse(event:ResultEvent):void {
  10.   try {
  11.     var json:Object = JSON.decode(event.result as String);
  12.     // now have some fun with the results...
  13.   } catch(ignored:Error) {
  14.   }
  15. }

If you are interested in this kind of thing, as well as Gears, OpenSocial, AppEngine, or Android, check out the Google Developer Days coming to cities around the world or our big Google I/O event on May 28-29 in San Francisco.

Posted by Dion Almaer at 9:07 am

4.2 rating from 23 votes


Comments feed TrackBack URI

Really exciting stuff, you can now with relative ease create web based search engines using the power of google bigTable and arrange / style the results how you see fit…

nice work google .. Kudos !

Comment by Jester — April 22, 2008

you are searching Paris Hilton and wants return format as “Text”? you have just offended miss Hilton. :-)

Comment by kadnan — April 23, 2008

Leave a comment

You must be logged in to post a comment.