This val was designed to be used in Google Sheets, particularly because Google Finance stopped supporting Spotify inexplicably.
- Copy and paste this into Google Sheets:
=IMPORTDATA(CONCATENATE("https://api.val.town/v1/run/stevekrouse.stockPrice?args=[%22","SPOT","%22]"))
- Replace "SPOT" with the symbol you want
This val currently uses Alpha Vantage's free plan (5 requests per minute & 500 per day).
You can sign up for your own API Key here: https://www.alphavantage.co/support/#api-key
Readme
1
2
3
4
5
6
7
async function stockPrice(symbol: string) {
let data = await stevekrouse.fetchJSON(
`https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=${symbol}&apikey=${@me.secrets.alphaVantage}`,
);
console.log(data);
return data["Global Quote"]["05. price"];
}
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.