So to my huge surprise, it seems impossible to get historical stock prices inside a Google Apps Script (for populating a google sheet) in any way. For some nice reason the scripts do not allow to call GoogleFinance and the FinanceApp does not exist anymore. Additionally, the Yahoo URL API no longer supports to be able to get historical stock. So how the heck is it possible to get stock prices data in a Google sheet via Script?
Asked
Active
Viewed 3,200 times
2

Cooper
- 59,616
- 6
- 23
- 54

Alex Botev
- 1,369
- 2
- 19
- 34
-
Pay for the data, from someone that offers the paid data? This isn't the place to request foreign resources like tutorials, API service recommendations, etc. – tehhowch Sep 17 '18 at 16:36
-
Well maybe I made phrased the question really bad, but what I'm asking is if there is any way which I have missed for getting the data from the Google Apps or the via web URL. Paying although an option is not really feasible for small personal projects, as well as it makes 0 sense to provide this service inside a sheet yet being somehow inaccessible via a script operating on a sheet. My main assumption is that I'm missing something and this is actually doable. – Alex Botev Sep 17 '18 at 16:49
-
[No, you cannot use Google Finance programmatically. That is by Google's design.](https://support.google.com/docs/answer/3093281?hl=en) Consider that they may have a some condition associated with their own access to that data, such that they are not allowed to support operations which would make competitor APIs possible. – tehhowch Sep 17 '18 at 17:10
-
@AlexBotev have you figured this out? I'm just starting with Apps Script and came across the same issue :( Would be good to know if you managed to resolve this somehow. Thank you :) – DashaLuna Aug 15 '23 at 08:56
2 Answers
2
There are plenty of other free sources of historical quotes (note that some require being logged in, or API keys):
https://www.quandl.com/api/v3/datasets/WIKI/AAPL.csv
https://stooq.com/q/d/l/?s=AAPL.US&i=d
https://api.iextrading.com/1.0/stock/aapl/chart/5y?format=csv
https://api.tiingo.com/tiingo/daily/AAPL/prices?startDate=2012-1-1&endDate=2016-1-1
And there are more...

OgreZed
- 41
- 3
1
Though Google cleary says they don't support GOOGLEFINANCE from the app script, but there is a way to improvise. You may use the following:
var ticker = cs.getRange(row_idx, ticker_column_idx).getValue();
formula="=GOOGLEFINANCE(" + '"' + ticker + '", ' + '"PRICE")';
cs.getRange(row_idx, price_col_idx).setValue(formula);

user3640820
- 71
- 1
- 6