Google Ajax Search API

CSE 190 M (Web Programming), Spring 2007

University of Washington

References: homepage, code samples, API reference

Except where otherwise noted, the contents of this presentation are © Copyright 2007 Marty Stepp and are licensed under the Creative Commons Attribution 2.5 License.

Valid XHTML 1.0 Strict Valid CSS!

Javascript frameworks

Many groups have released Javascript frameworks you can include in your web pages to add effects:

What is the Google Ajax Web API?

Google code

API keys

<script src=";v=1.0&amp;key= ABQIAAAAjwpa3Lmr7L0oXrBemAIp0BSx0OSUw7R9ozDoChrVVXrbgKdJeBTWWRQkTwM5gxzSfgnTYruTJLircA" type="text/javascript"></script>

Ways of using the API

"Hello, World!" app

// in your window.onload handler:
var searchControl = new GSearchControl();
searchControl.addSearcher(new search());

Search control example

The search objects

search objectanalogous to

Methods/properties common to all searches

Web search example

var search = new Search();
search.setSearchCompleteCallback(window, function() {
    for (var i = 0; i < search.results.length; i++) {
        do something with search.results[i];
var search = new GwebSearch();
search.setSearchCompleteCallback(window, function() {
    for (var i = 0; i < search.results.length; i++) {
search.execute("miserable failure");

Web search: GwebSearch

Local search: GlocalSearch

Video search: GvideoSearch

Blog search: GblogSearch

News search: GnewsSearch

Book search: GbookSearch

Practice problem: Google Fight