Hacking Google Maps and Google Earth (ExtremeTech)

(Dana P.) #1

Chapter 4 — The Google Web API 55


You cannot use the Google Web API to build a site for commercial purposes without
prior agreement with Google.
You are limited to a maximum of 1,000 queries a day. This averages to one query every
86 seconds, so it pays to be careful with your queries; limit, cache, or count your queries
to ensure that you can still get the information when you need it. If you rely on the
Google Web API for supporting functionality in your web site, and your web site
becomes popular, hitting the 1,000 query limit in a typical day is inevitable.

Google will return a maximum of 10 results per query, even though your query may actu-
ally be made up of many more results than this. Because of this, large searches may
require multiple queries, increasing your daily query count on each occasion.

If you have any questions, check the terms and conditions and the FAQ section on the Google
Web API site.


Remember to take note of the limits and usage on your key, which is tied to your Google
account. In theory, you could create multiple accounts, obtaining multiple keys to increase the
number of queries you can make per day. Over the long term, however, you run the risk of
Google revoking or restricting your access and your ability to use the service and to obtain addi-
tional keys.


Conducting Searches


Once you have your access key, you can start submitting queries to the system. This relies on
using web services with a number of parameters to specify the information you are searching
for. You also need to understand the format of the results, how the information can be used,
and what the limitations of the data that you extract are.


Parameters


Regardless of what language you are using, the Simple Object Access Protocol (SOAP) inter-
face to the Google web service works in the same way: You supply the parameters for the
search and Google returns a structure with the search results.


Table 4-1 shows the parameters to the remote function.


Table 4-1: Google Web Search API Arguments

Parameter Description

Key The access key provided by Google.
Query string The query string that defines what you are searching for.
Start index The index of the first result to be returned within the query.
Max results The maximum number of results to return. Note that you can never
obtain more than 10 results.

Continued
Free download pdf