The Google Finance and Google Data APIs teams are pleased to announce the release of a Google Data API for the Google Finance portfolios. I have already promised that I would spend some time on testing some things for this new API. So I now finaly found some time to check this new API. To be honest I had to check google finance first because I never made use of it.
The cool thing about the new API is that you will be able to download information from Google finance in a XML format so you will be able to use it in all kind of applications. Think about the possibilities of downloading this information to your application and maybe even use Google maps API and the Google chart API. You can make for example a very nice online application to show the world markets and how they behave…. Think about all those other cool things you always wanted to code in combination with stock information. You are now able to. Google, great news! Thanks!
In the upcoming days I will post a couple of posts about this new API but we will start at the beginning. How do you get access to data? Google finance is using your standard Google login information so you will not be needing a separate developers key or anything.
You can make use of two ways of authenticating to google finance. The first is “AuthSub proxy authentication” and the second one is “ClientLogin username/password authentication”. I will in this post not go into details about “AuthSub proxy authentication”, this I will save for an other post. I will now be discussing “ClientLogin username/password authentication”.
By making use of this option your “visitors” will have to provide their username and password for Google to you, so this can be the downside of this approach because they really have to trust you. However this is a side issue. After the user has provided you with the username and password you will have to request an authorization token (Auth) from google.
You will have to do a post to https://www.google.com/accounts/ClientLogin with the following parameters: Email, Passwd, service and source.
Email : The user's email address.
Passwd : The user's password.
Service : finance
Source : Identifies your client application. Should take the form companyName-applicationName-versionID.
The google API documentation states that you have to do a post with the content type application/x-www-form-urlencoded. On how you can get this from for example a php site you can take a look at ngoprek web weblog. There are also some other good examples on how to get the auth token from google.
Currently the API documentation is only showing examples in java in the Java client library so in my next post I will be trying to have a small example of a java web application which is interacting with the Google Finance API.