I’m trying to use I’m trying to use eodhd free plan API (registered to free plane) to get the live price (or close price) for some ETFs.
-
This apps-script code return “data.close” = “NA”
-
I’ve installed your google-sheet extension, but can it fill the price in one of my specific cells?
ETFs are: ZRPX, ZPRV, AVWS
- This apps-script code return “data.close” = “NA”
symbol = "AVWS";
var apiKey = 'MY_API_KEY'; // I put it when I run!
var apiUrl = 'https://eodhistoricaldata.com/api/real-time/' + symbol + '.US?api_token=' + apiKey + '&fmt=json';
try {
var response = UrlFetchApp.fetch(apiUrl, {muteHttpExceptions: true});
if (response.getResponseCode() === 401) {
throw new Error('Unauthorized: Please check your API key and permissions.');
}
var data = JSON.parse(response.getContentText());
if (!data || !data.close) {
throw new Error('Invalid symbol or data not available.');
}
var price = parseFloat(data.close);
if (isNaN(price)) {
throw new Error('Price data not available.');
}
return price;
} catch (error) {
return 'Error: ' + error.message;
}
}
- I’ve installed your google-sheet extension, but can it fill the price in one of my specific cells?
ETFs are: ZRPX.F, ZPRV.F, AVWS.DE