2

Post 6th September

I am working on a project where I want to display live prices from Google Finance API for multiple stock with information like change change in % volume Timestamp of data

and

few ratios like ROI/E, ROA, Net-profit-margin -- This is completely optional. (If available then amazing if not then still not much of a issue.)

Sending one request for every stock is absurd when it comes to efficiency.

I tried multiple things like

https://finance.google.com/finance?q=NSE:ABAN,NSE:ABB&output=json

This gave me the basic info of the stocks but not the live prices.

https://finance.google.com/finance?q=NSE:ABAN,ABB&output=json

This query just acknowledged that the stock with name ABAN exists.

I am interested in NSE (National Stock Exchange-India)'s data. I already went through 2-3 threads for this matter but couldn't get much info, also Yahoo stopped support for Indian markets so that option is also crossed of the list as well.

The project is academic so I would want a free source for the data if possible.

Any help regarding this will really be really appreciated.

Shreyansh Lodha
  • 83
  • 2
  • 10

1 Answers1

5

Update: Google killed it.

You can do the following trick:

  1. Query IDs for the stocks you need (you can do this once, the IDs seems to be permanent):

https://finance.google.com/finance?output=json&q=,,... (up to 14 stocks per query)

The output would have the 'id' field that you should collect. Example:

{...
"searchresults" : [
{
"title" : "Aban Offshore Ltd",
"id" : "3302534",
"ticker" : "ABAN",
"exchange" : "NSE",
...
} , {
"title" : "ABB India Ltd",
"id" : "5296497",
"ticker" : "ABB",
"exchange" : "NSE",
...
}]
...
  1. Query information using the IDs:

https://finance.google.com/finance/data?dp=mra&output=json&catid=all&cid=3302534,5296497,... (don't know the limit but it's way more than 14 IDs)

the output will have info about every ID

{...,company:{related:{cols:[...],
rows:[
{id:"3302534",
values:["3302534","ABAN","Aban Offshore Ltd","ABAN","NSE","INR","178.35","+0.40","chg","0.22","","-184.19","","0.39","0.59","10.41B","","0.00","","0.63","63.15","74.78","448.77","531.41","-5.34","-32.89","-6.46","1.40","-59.21","93.14","52.77","12.88","1,275","17,579.20","-10,408.33","9,275.71"]},
{id:"5296497",
values:["5296497","ABB","ABB India Ltd","ABB","NSE","INR","1,365.20","+24.00","chg","1.79","","17.88","76.36","8.66","3.09","289.56B","","4.00","0.30","1.56","7.76","7.76","18.28","18.28","4.95","11.90","9.86","1.43","4.08","32.94","7.56","5.92","5,603","91,840.50","3,744.70","6,945.30"]}],
visible_cols:[...]}}}

The columns are: ID, Ticker, Name, Ticker, Exchange, Currency, Price, Change, Unknown, Change%, Unknown, EPS, PE, PB, PS, Cap, EntValue, Div, DivYield, CurrRatio, LtDebtToAssets, TotalDebtToAssets, LtDebtToEquity, TotalDebtToEquity, ReturnOnAvgAssets, ReturnOnAvgEquity, ReturnOnAvgInvestment, Beta, NetProfitMargin, GrossMargin, EBITDMargin, OperatingMargin, Employees, Revenue, NetIncome, EBITDA

Unfortunately there's no extended session price or any of the last trade times. If you know how to get the last trade time for a stock, please let me know.

  • First of all thank you so much for the detailed description, I just want to confirm that is this the right order(second method) that you have posted for the columns? And also is there any way to verify this? – Shreyansh Lodha Sep 12 '17 at 01:27
  • The columns were derived from comparing the data from json with data on the finance page. I wish there could be more reliable source for those but I haven't found anything better so far. –  Sep 13 '17 at 02:38
  • Now it has been moved! – Ravi Parekh Apr 02 '18 at 06:00
  • It does not work, gives 200 response and some HTML content, not JSON. – Ayush Oct 21 '18 at 04:40
  • Pretty much all Google Finance API is long dead, unfortunately. –  Jan 26 '19 at 06:17