2

I am trying to get the realtime stockquotes from google for some time now. First I try'd the finance api, but that didd'nt work out.

Then I saw this query and it seems to good to be true

http://www.google.com/finance/info?client=ig&q=goog

It must have some drawbacks that I am not aware off now.

Anyway, it does give realtime, at least that what it is says on the google finance page

Does anyone know if I can add more parameters for the query like + YAHOO (this is falty) so I can get more then one stock??

Also, is the output in json or do Y have to parse it differently? I was planning to do this with curl and ajax

thanks, Richard

Richard
  • 4,516
  • 11
  • 60
  • 87

2 Answers2

2

You can just add more ticker symbols with a comma, as in:

http://www.google.com/finance/info?client=ig&q=goog,msft

The response is indeed json. There is a good discussion on Stackoverflow about using the first-class Google Finance APIs to get stock quotes here: How can I get stock quotes using Google Finance API?

Community
  • 1
  • 1
Chris Clark
  • 4,544
  • 2
  • 22
  • 22
  • Thanks for the comma. I did came across that post, I remember, Anyway there is no real good tutorial, yet, about how to get stockquotes. The current tradevalue, etc. Not straighforward anyway. – Richard Dec 30 '09 at 15:22
1

comma seperate your sybols. http://www.google.com/finance/info?client=ig&q=goog,osis

gingerbreadboy
  • 7,386
  • 5
  • 36
  • 62
  • Thanks, do you also perhaps know what makes the json valid, because I did ltrim($string,'/') to get rid of the forward slashes? – Richard Dec 30 '09 at 15:35
  • Someone suggested the slashes are to invalidate the json, forcing you to parse it somehow (as you have done above) as some kind of security thing, but I dunno about that sort of thing :) – gingerbreadboy Dec 30 '09 at 15:49
  • Thanks, I got an associative array I think, I am now reading the php manuel to extract a single value. – Richard Dec 30 '09 at 15:57
  • It's an array within an array, I have read that eval is never good, if you can do it in another way. So I will explore that first. – Richard Dec 30 '09 at 16:22