Skip to content


Google API – AS3 Library

A while ago, I have build an API library in AS3 that interfaces with Google’s own AJAX API. To show you how performant this API is, I included a demo-app at the bottom of this blog.

The library is a simple collection of the API’s features, there is a class per feature, like Google Web search, Images Search, etc. Each library throws it’s own event with an Array of matching datatypes, for example GoogleWebItem, so it’s easy to keep track on wich data is recieved and what this data contains.

This api contains:

  • Google Web Search
  • Google Images Search
  • Google Book Search
  • Google Video Search (Google Video & YouTube)
  • Google Blog Search
  • Google Local Search
  • Google Patent Search
  • Google News Search
  • Google Translation
  • Google Weather
  • Google Suggest (new)

This API is Flash & Flex compatible.

Little example code

var googleWebSearch:GoogleWebSearch=new GoogleWebSearch()
 
googleWebSearch.search(txtInput.text,0,lang)
googleWebSearch.addEventListener(GoogleSearchEvent.WEB_SEARCH_RESULT,onWebResults) 
 
private function onWebResults(e:GoogleSearchEvent):void{
   for each (var result:GoogleWebItem in e.data as Array){
      trace(result.title, result.url)
   }
}

The library

You can download the library here (updated).
The demo app can be found here.

Right-click in the app to see source-code.

Posted in AIR, AS3, BoulevArt, Flash, Flex.


3 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. myfree9 says

    hello,Joris Timmerman:

    Thank you for your as3 library.

    but it can not work in flex website(not AIR).

    —–
    Hello,
    Whats seems to be the problem?
    I got a working demo online; build in flex: http://www.joristimmerman.be/googletest/
    Right click to see the source.

  2. Ella Robinson says

    is there a search engine that is dedicated more on searching videos ?,,*

  3. amit shakya says

    Hi I have tried your code in flash but it showing compilation error.

    ReferenceError: Error #1065: Variable com.adobe.utils::StringUtil is not defined.
    at be.boulevart.google.ajaxapi.search.web::GoogleWebSearch/search()
    at search3_fla::MainTimeline/frame1()

    and I am not clear from documentation that where I need to put API key???



Some HTML is OK

or, reply to this post via trackback.