Google's Undocumented Finance API

Written by NetworkError, on 18-05-2013 16:25
Views 63844

I've been playing around with the undocumented Google Finance API. It provides intra-day data for the past 10 days and day-granularity data going back for years. Handy!

There are lots of web pages that attempt to describe how this thing works. I've pulled together a bunch of data from them, as well as a few of my own observations. You can watch this thing in action by popping open FireBug while messing about on with the google finance chart. It will make AJAX requests to this API.

Here's an example URL to pull all historical data for GOOG at daily granularity:

What do all the parameters mean? Here's a partial list:

q - Stock symbol
x - Stock exchange symbol on which stock is traded (ex: NASD)
i - Interval size in seconds (86400 = 1 day intervals)
p - Period. (A number followed by a "d" or "Y", eg. Days or years. Ex: 40Y = 40 years.)
f - What data do you want? d (date - timestamp/interval, c - close, v - volume, etc...) Note: Column order may not match what you specify here
df - ??
auto - ??
ei - ??
ts - Starting timestamp (Unix format). If blank, it uses today.

The output includes a header that describes the columns, timezone offset, and a few other interesting bits of information. The data rows are basically CSV format.

One tricky bit with the first column (the date column) is the full and partial timestamps. The full timestamps are denoted by the leading 'a'. Like this: a1092945600 The number after the 'a' is a Unix timestamp. (Google it if you're not sure what it is.) The numbers without a leading 'a' are "intervals". So, for example, the second row in the data set below has an interval of 1. You can multiply this number by our interval size (a day, in this example) and add it to the last Unix Timestamp. That gives you the date for the current row. (So our second row is 1 day after the first row. Easy.)

Sample output format:

a1092945600,100.335,104.06,95.96,100.01,22353092,1 <-- a##### denotes a unix time stamp.

1,108.31,109.08,100.5,101.48,11429498,1 <-- The first column (1) * interval (1 day) + last full unix time stamp = date
11,102.01,105.49,102.01,105.49,2601620,1 <-- Note:  We jumped from 8 to 11.  We skipped 2 days.  This was a weekend.

Hopefully this gives you what you need to build your own stock data-feed. Happy hacking!

Last update: 18-05-2013 16:25

Published in : Public, Technical Wootness

Users' Comments (3)
Posted by stephane, on 25-12-2017 17:14, IP, Registered
1. What about headers ?
What's the meaning of these headers in the file ?
» Report this comment to administrator
» Reply to this comment...

Posted by Holden, on 14-06-2017 02:40, IP, Registered
2. Multiple Symbols in a single query
Can you query for multiple stock symbols with a single query? If so how many?
» Report this comment to administrator
» Reply to this comment...

Posted by Arulraj V, on 02-08-2015 09:47, IP, Registered
3. Python file to get that as proper csv
http://trading.cheno.net/wp- content/uploads/2011/12/ google_intraday.py Here is the python file to get the data with manipulated date
» Report this comment to administrator
» Reply to this comment...
» See all 1 replie(s)

Add your comment

mXcomment 1.0.7 © 2007-2018 - visualclinic.fr
License Creative Commons - Some rights reserved