Stay organized with collections
Save and categorize content based on your preferences.
Monday, October 13, 2008
The
Webmaster Tools GData API
has been updated to allow you to get even more out of Webmaster Tools, such as
setting a geographic location
or your
preferred domain.
For those of you that aren't familiar with
GData,
it's a protocol for reading and writing data on the web. GData makes it very easy to communicate
with many Google services, like Webmaster Tools. The Webmaster Tools GData API already allows you
to add and verify sites for your account and to submit Sitemaps programmatically. Now you can also
access and update site-specific information. This is especially useful if you have a large number
of sites. With the Webmaster Tools API, you can perform hundreds of operations in the time that it
would take to add and verify a single site through the web interface.
What can I do?
We've included four new features in the API. You can see and update these settings for each site
that you have verified. The features are:
Crawl Rate: You can request that Googlebot crawl your site slower or faster than it
normally would (the details can be found in our
Help Center article about crawl rate control).
If many of your sites are hosted on the same server and you know your server's capacity, you
may want to update all sites at the same time. This now a trivial task using the Webmaster
Tools GData API.
Geographic Location: If your site is targeted towards a particular geographic location
but your domain doesn't reflect that (for example with a .com domain), you can
provide information
to help us determine where your target users are located.
Preferred Domain: You can select which is the canonical domain to use to index your
pages. For example, if you have a site like www.example.com, you can set either example.com or
www.example.com as the preferred domain to use. This avoids the
risk of treating both sites differently.
Enhanced Image Search: Tools like the
Google Image Labeler
allow users to tag images in order to improve Image Search results. Now you can opt in or out
for all your sites in a breeze using the Webmaster Tools API.
How do I do it?
We provide you with
Java code samples
for all the current Webmaster Tools API functionality. Here's a sample snippet of code that takes
a list of sites and updates the geographic location of all of them:
// Authenticate against the Webmaster Tools service
WebmasterToolsService service;
try {
service = new WebmasterToolsService("exampleCo-exampleApp-1");
service.setUserCredentials(USERNAME, PASSWORD);
} catch (AuthenticationException e) {
System.out.println("Error while authenticating.");
return;
}
// Read sites and geolocations from your database
readSitesAndGeolocations(sitesList, geolocationsList);
// Update all sites
Iterator sites = sitesList.iterator();
Iterator geolocations = geolocationsList.iterator();
while (sites.hasNext() && geolocations.hasNext()) {
// Create a blank entry and add the updated information
SitesEntry updateEntry = new SitesEntry();
updateEntry.setGeolocation(geolocations.next());
// Get the URL to update the site
String encodedSiteId = URLEncoder.encode(sites.next(), "UTF-8");
URL siteUrl = new URL("https://www.google.com/webmasters/tools/feeds/sites/" + encodedSiteId);
// Update the site
service.update(siteUrl, updateEntry);
}
Where do I get it?
The main page for the
Webmaster Tools GData API
explains all the details of the API. It has a detailed reference guide and also many code
snippets that explain how to use the Java client library, which is
available for download.
You can find more details about GData and all the different Google APIs in the
Google Data API home page.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],[],[[["\u003cp\u003eThe Webmaster Tools GData API has been updated to allow programmatic access and modification of website settings, including crawl rate, geographic location, preferred domain, and Enhanced Image Search participation.\u003c/p\u003e\n"],["\u003cp\u003eUsing the API, webmasters with multiple sites can efficiently manage settings, such as adjusting crawl rate for sites on the same server or setting geographic targeting.\u003c/p\u003e\n"],["\u003cp\u003eJava code samples and documentation are available to guide developers in using the Webmaster Tools GData API.\u003c/p\u003e\n"],["\u003cp\u003eThe API simplifies tasks like setting preferred domains, preventing duplicate content issues, and managing Enhanced Image Search preferences for numerous websites.\u003c/p\u003e\n"]]],["The Webmaster Tools GData API has been updated, adding four new features for verified sites: crawl rate control, geographic location setting, preferred domain selection, and enhanced image search opt-in/out. These features allow users to adjust how Google crawls their site, specify target locations, choose a preferred domain, and manage image search tagging. Java code samples are provided to demonstrate how to programmatically access and modify these settings, allowing for efficient management of numerous sites.\n"],null,["# Webmaster Tools API updated with Site Settings\n\nMonday, October 13, 2008\n| It's been a while since we published this blog post. Some of the information may be outdated (for example, some images may be missing, and some links may not work anymore).\n\n\nThe\n[Webmaster Tools GData API](https://code.google.com/apis/webmastertools/)\nhas been updated to allow you to get even more out of Webmaster Tools, such as\n[setting a geographic location](https://www.google.com/support/webmasters/bin/answer.py?answer=62399)\nor your\n[preferred domain](https://www.google.com/support/webmasters/bin/answer.py?answer=44231).\nFor those of you that aren't familiar with\n[GData](https://code.google.com/apis/gdata/),\nit's a protocol for reading and writing data on the web. GData makes it very easy to communicate\nwith many Google services, like Webmaster Tools. The Webmaster Tools GData API already allows you\nto add and verify sites for your account and to submit Sitemaps programmatically. Now you can also\naccess and update site-specific information. This is especially useful if you have a large number\nof sites. With the Webmaster Tools API, you can perform hundreds of operations in the time that it\nwould take to add and verify a single site through the web interface.\n\nWhat can I do?\n--------------\n\n\nWe've included four new features in the API. You can see and update these settings for each site\nthat you have verified. The features are:\n\n- **Crawl Rate:** You can request that Googlebot crawl your site slower or faster than it normally would (the details can be found in our [Help Center article about crawl rate control](https://www.google.com/support/webmasters/bin/answer.py?answer=48620)). If many of your sites are hosted on the same server and you know your server's capacity, you may want to update all sites at the same time. This now a trivial task using the Webmaster Tools GData API.\n- **Geographic Location:** If your site is targeted towards a particular geographic location but your domain doesn't reflect that (for example with a .com domain), you can [provide information](https://www.google.com/support/webmasters/bin/answer.py?answer=62399) to help us determine where your target users are located.\n- **Preferred Domain:** You can select which is the canonical domain to use to index your pages. For example, if you have a site like www.example.com, you can set either example.com or www.example.com as the preferred domain to use. This avoids the [risk of treating both sites differently](https://www.google.com/support/webmasters/bin/answer.py?answer=44231).\n- **Enhanced Image Search:** Tools like the [Google Image Labeler](https://images.google.com/imagelabeler/) allow users to tag images in order to improve Image Search results. Now you can opt in or out for all your sites in a breeze using the Webmaster Tools API.\n\nHow do I do it?\n---------------\n\n\nWe provide you with\n[Java code samples](https://code.google.com/p/gdata-java-client/)\nfor all the current Webmaster Tools API functionality. Here's a sample snippet of code that takes\na list of sites and updates the geographic location of all of them: \n\n```\n// Authenticate against the Webmaster Tools service\nWebmasterToolsService service;\ntry {\n service = new WebmasterToolsService(\"exampleCo-exampleApp-1\");\n service.setUserCredentials(USERNAME, PASSWORD);\n} catch (AuthenticationException e) {\n System.out.println(\"Error while authenticating.\");\n return;\n}\n\n// Read sites and geolocations from your database\nreadSitesAndGeolocations(sitesList, geolocationsList);\n\n// Update all sites\nIterator sites = sitesList.iterator();\nIterator geolocations = geolocationsList.iterator();\nwhile (sites.hasNext() && geolocations.hasNext()) {\n // Create a blank entry and add the updated information\n SitesEntry updateEntry = new SitesEntry();\n updateEntry.setGeolocation(geolocations.next());\n\n // Get the URL to update the site\n String encodedSiteId = URLEncoder.encode(sites.next(), \"UTF-8\");\n URL siteUrl = new URL(\"https://www.google.com/webmasters/tools/feeds/sites/\" + encodedSiteId);\n // Update the site\n service.update(siteUrl, updateEntry);\n}\n```\n\nWhere do I get it?\n------------------\n\n\nThe main page for the\n[Webmaster Tools GData API](https://code.google.com/apis/webmastertools/)\nexplains all the details of the API. It has a detailed reference guide and also many code\nsnippets that explain how to use the Java client library, which is\n[available for download](https://code.google.com/p/gdata-java-client/).\nYou can find more details about GData and all the different Google APIs in the\n[Google Data API home page](https://code.google.com/apis/gdata/).\n\nWritten by Javier Tordable, Software Engineer"]]