The Google AJAX Search API is designed to make it easier for webmasters and developers to do two things:
Check out the API Documentation for more details.
In most cases it should be clear whether your usage of the AJAX APIs complies with the posted Terms of Use. However if you are still unclear, and have a strong vested interest in resolving any confusion, it is best to consult a lawyer who can give professional legal advice on this. Google engineers can only offer technical advice in the forum and are not qualified to offer legal advice.
The Developer Guide can be found at http://code.google.com/apis/ajaxsearch/documentation/.
The AJAX Local Search API supports all of the countries which have local business information indexed. That is, any local listing results found on Google's Local Search will also be available via the API.
Simply sign up for an API key and you can add a Google AJAX Search module to your site. See the AJAX Search API documentation for examples and details.
Check out our usage samples to get a sense for what you can do with the AJAX Search API. That page includes things like Map Search, Video Search, and Video Bar solutions, which are snippets of code you can copy-and-paste into your site for some powerful functionality. We often announce new samples and solutions in our blog.
The AJAX Search API includes "clipping" functionality that makes it easy for users to insert Google search result content into your site. This means you could give your users a way to:
No, once Google search results are clipped and added to your site, they are mostly static -- Google won't control or update the text on your site, although the content that Google hosts such as video thumbnail images may disappears from your site if they are removed from Google's index.
The AJAX Search API is still in its early stages, hence the "1.0" version number. It won't likely change as dramatically as its first few months (when it was a v0.1), but you can expect that we'll continue to add features and make significant changes based on developer feedback.
The AJAX Search API is available for sites that are accessible to their end users without charge. You can use the API on both commercial and non-profit websites as long as your site meets the terms of use.
Please bear in mind that Google can't officially "sign off" on every website that uses this API, so it's your responsibility to make sure your site meets the terms of use before you develop and launch it. Google reserves the right to suspend or terminate your use of the service at any time, so please read the terms of use carefully.
Yes, it is, as long your site is accessible to your end users without charge. For example, if your website is supported by advertising, it likely falls within the terms of the AJAX Search API.
However, not all commercial uses are allowed. For example:
Remember, Google reserves the right to suspend or terminate the use of the service at any time, so please read the terms of use carefully.
Yes! We want to make it clear that you can use these APIs in the context of websites, gadgets, mobile apps, desktop client apps, etc.
Sorry, but no; the AJAX Search API is the only permissible way to publish Google AJAX Search API results on your site. We'll block your application if it accesses search results outside of the API.
You may optionally use an API key which you’ll include in the URL with which you access the API. We’ll use that key to track API usage.
The key you receive in the signup process is valid for a directory, and any subdirectories below that directory, on your website. If you sign up for the directory http://www.mygooglesearchsite.com/mysite, your key is valid for these URLs:
http://www.mygooglesearchssite.com/mysite/http://www.mygooglesearchsite.com/mysite/mypage.htmlhttp://www.mygooglesearchsite.com/mysite/page?arg=foohttp://www.mygooglesearchsite.com/mysite/subdir/page.htmlThe key will not be valid for these URLs:
http://differenthost.mygooglesearchsite.com/mysitehttp://www.mygooglesearchsite.com/
The Google AJAX Search API is currently available on Firefox 1.5+, Safari, Opera 9+, and IE 6+.
If you make use of the AJAX Search API's "clipping" functionality, which enables users to insert Google search result content into your site, it is your responsibility to respond to user concerns about that content. You must provide users with a way to contact you and let you know about problems, and remove the clipped search result content from your page if appropriate. For example, a business should be able to reach you if a local search result clipped from Google onto your site shows the wrong phone number. You should know that for copyright complaints, US law provides a specific process that you can use for removing content. Information about Google's own process, which may be a helpful reference, is in our DMCA policy
Please post your question in the Google AJAX Search API discussion group to get help from the Google AJAX Search API developer community. The AJAX Search API team also participates in this group to answer questions.
The Google AJAX API loader makes it easier to use multiple Google AJAX APIs on the same page and unifies the namespaces across them. Instead of adding a separate script tag for each API, this loader gives you a common way to load multiple APIs at once.
With the Google AJAX API loader, you can use a single script tag,
whether you're using a single AJAX API or several. The loader
is loaded using a script tag of:
<script type="text/javascript" src="http://www.google.com/jsapi?key=YOUR-KEY"></script>
Once you have the loader available, you can request additional modules using the google.load() method:
<script type="text/javascript">
google.load("feeds", "1");
google.load("search", "1");
</script>
No. If you prefer to leave your working code alone, that's fine.
We'll continue to update and maintain the G* naming
scheme alongside the google.* naming scheme.
For more information on the AJAX API loader, please see the documentation.
The benefit of techniques #1 and #2 is that all of the user interface is pre-designed for you and they are very easy to integrate into your page. They also have a fair amount of customizable options.
The upside to option #3 is that you have full control over your search and results. This means you can create your own user interface then design how the results are displayed.
Choosing which option to use should depend on the requirements of your application. Simply put, if you just want a quick search box on your page then options #1 and #2 are the way to go. But if you are looking to have a customized experience or to make custom modifications to the Search Control or Wizards then you might save time by writing your own "Raw Searcher".
Use the setSearchCompleteCallback method. It lets you set a function to be called when the search has completed.
If you are using the Search Control, here is how you would use the setSearchCompleteCallback:
function searchComplete(searchControl, searcher) {
for (var i=0; i < searcher.results.length; i++) {
// Do whatever you want with the results
}
}
function OnLoad() {
var searchControl = new google.search.SearchControl();
var webSearch = new google.search.WebSearch();
searchControl.addSearcher(webSearch);
searchControl.draw(document.getElementById("searchcontrol"));
searchControl.setSearchCompleteCallback(this, searchComplete);
searchControl.execute('Google')
}
google.setOnLoadCallback(OnLoad);
Notice that the SearchControl and searcher are automatically passed to the searchComplete function. When a search is complete, the searcher contains the results.
Using setSearchCompleteCallback on a single searcher (a.k.a. Raw Searcher) is slightly different. It looks like this:
function searchComplete(searcher) {
for (var i=0; i < searcher.results.length; i++) {
// Do whatever you want with the results
}
}
function OnLoad() {
var webSearch = new google.search.WebSearch();
webSearch.setSearchCompleteCallback(this, searchComplete, [webSearch]);
webSearch.execute('Google')
}
google.setOnLoadCallback(OnLoad);
In order to get the searcher object (and results) into the searchComplete function we have to pass it as a parameter in the setSearchCompleteCallback method. Each parameter in the array will be passed as an argument to the callback function.
If you are using one of the wizards (Blog Bar, News Bar etc.) then you will have to edit its Javascript file in order to get access to these results.
Use the setSearchStartingCallback method if you are using a SearchControl. If you are using Raw Searchers you should create the input form with the google.search.SearchForm which has a setOnSubmitCallback method. These methods allow you to specify a function that will be called when a query is made -- then you can store what that query was. You can access the query in a Search Control with the third parameter that is passed into the callback and from the SearchForm with searchForm.input.value.
Here is some sample code for doing it with a Search Control:
function searchComplete(searchControl, searcher, query) {
alert(query);
}
function OnLoad() {
var searchControl = new google.search.SearchControl();
var webSearch = new google.search.WebSearch();
searchControl.addSearcher(webSearch);
searchControl.draw(document.getElementById("searchcontrol"));
searchControl.setSearchStartingCallback(this, searchComplete);
searchControl.execute('Google')
}
google.setOnLoadCallback(OnLoad);
In stacked mode, the SearchControl offers what's called ExpandMode, which can be set to open or closed on a per-searcher basis. By default, ExpandMode is set to closed when a searcher is added to the control, resulting in only one result being displayed. To override this behavior, use a SearcherOptions object, as below:
var searchControl = new google.search.SearchControl();
var searcher = new google.search.WebSearch();
var options = new google.search.SearcherOptions();
options.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN);
searchControl.addSearcher(searcher,options);
searchControl.draw(document.getElementById('my_element');
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
There are no restrictions on using it. You can use it to do whatever you like. Copy and paste it, use it whole, whatever you like. The only requirement is that you maintain the copyright notice that is there now.
The default state of things in the world of copyright is that "if nobody has given you permission, you generally have no right to use it" (there are exceptions, this is just the general rule). In order to make it clear that we want people to reuse and share this sample code, we explicitly use a license that lets you do this.
We use the Apache license over the BSD/MIT/etc for a simple reason: It grants you patent rights.