Current Stock Price

This val was designed to be used in Google Sheets, particularly because Google Finance stopped supporting Spotify inexplicably.

Usage

  1. Copy and paste this into Google Sheets:
=IMPORTDATA(CONCATENATE("https://api.val.town/v1/run/stevekrouse.stockPrice?args=[%22","SPOT","%22]"))
  1. Replace "SPOT" with the symbol you want

API

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
8
9
10
import process from "node:process";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
export async function stockPrice(symbol: string) {
let data = await fetchJSON(
`https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=${symbol}&apikey=${process.env.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.