HomeGuidesHow to get stock prices in Google Sheets
How to get stock prices in Google Sheets
Get stock prices in Google Sheets with a DINO_PRICE custom function in Apps Script. The key stays in Script Properties, and a 5 minute cache saves requests.
dino.markets is a financial data API for apps and AI agents with stocks and ETFs on 42 exchanges, a free plan and paid plans from $29 a month (as of November 2026). This guide adds a DINO_PRICE function to Google Sheets with Apps Script, so =DINO_PRICE("MSFT") returns the latest price of Microsoft. The whole script is below, and the sections after it explain each part.
const API = "https://api.dino.markets/v1";
function readBody(response) {
const status = response.getResponseCode();
let body;
try {
body = JSON.parse(response.getContentText());
} catch (e) {
throw new Error(status + " Not a JSON answer");
}
if (status !== 200) throw new Error(status + " " + body.code);
return body;
}
function DINO_PRICE(ticker) {
if (!ticker) return "";
const id = String(ticker).trim().toUpperCase();
if (!/^[A-Z0-9.:-]+$/.test(id)) throw new Error("Not a ticker: " + id);
const cache = CacheService.getScriptCache();
const hit = cache.get(id);
if (hit) return Number(hit);
const key = PropertiesService.getScriptProperties().getProperty("DINO_API_KEY");
if (!key) throw new Error("Add DINO_API_KEY in Script Properties");
const response = UrlFetchApp.fetch(API + "/equities/" + id + "/price", {
headers: { Authorization: "Bearer " + key },
muteHttpExceptions: true,
});
const body = readBody(response);
cache.put(id, body.price, 300);
return Number(body.price);
}
Before you start
- A Google account and a Google Sheet.
- A dino.markets API key.
- Each successful request counts against your plan’s monthly limit. Failed requests do not count.
- Google limits how many fetches a script may make in a day. Free Google accounts get 20,000.
Get a key
Sign up for the Free plan, which needs no card. Then open keys in the dashboard and create a key. Anyone who can edit the sheet can reach the script, so make a key just for this sheet.
Open Apps Script
Open your sheet. Choose Extensions, then Apps Script. Delete the sample code, paste the script from the top of this page and save.
Keep the key out of the cell
Do not type the key into a cell or into the code. A cell is visible to everyone with the sheet, and a function argument is not secret.
In the Apps Script editor, open Project Settings in the left bar. Under Script Properties, choose Add script property. Enter DINO_API_KEY as the property and your key as the value, then save.
The function reads the key from there with PropertiesService. Viewers of the sheet can see the results but not the script.
Make the request
The function calls GET /v1/equities/{id}/price with the key in an Authorization header. dino.markets reads the key only from that header and refuses keys in the address. The id can be a bare US ticker such as MSFT, or the exchange code, a colon and the ticker, for example XNAS:MSFT.
The response is shown below.
Example response from 13 November 2026. The price changes all day, the fields stay the same.
{
"id": "XNAS:MSFT",
"symbol": "MSFT",
"currency": "USD",
"price": "522.10",
"previous_close": "523.00",
"change": "-0.90",
"change_percent": "-0.17",
"volume": "128104",
"market_session": "open",
"timestamp": "2026-11-13T14:59:00Z",
"stale": false,
"delayed": true
}
The price is a decimal string, so the function turns it into a number with Number().
Use it in a cell
Go back to the sheet and type this in a cell.
=DINO_PRICE("MSFT")
The cell shows the price, for example 522.10. You can also point at another cell, so with MSFT in A2, =DINO_PRICE(A2) works and a list of tickers fills down.
The first time, Google asks you to authorize the script because it contacts another service. Allow it. If a cell still shows an authorization error, open Apps Script, run any function from the editor once and accept the prompt.
Get the change as well
To show the price and the change today, return both from one call. Two separate functions would make two calls.
function DINO_QUOTE(ticker) {
const id = String(ticker).trim().toUpperCase();
const key = PropertiesService.getScriptProperties().getProperty("DINO_API_KEY");
const response = UrlFetchApp.fetch(API + "/equities/" + id + "/price", {
headers: { Authorization: "Bearer " + key },
muteHttpExceptions: true,
});
const body = readBody(response);
return [[Number(body.price), Number(body.change_percent)]];
}
Use it as =DINO_QUOTE("MSFT"). A function that returns a list of lists fills the cells next to it, one column for each value. It uses the same readBody function, so errors look the same. This one skips the cache, so add the same cache lines if you use it a lot.
Handle errors
Errors come back as problem JSON with a code. Read the errors guide for the full list. Both functions put the status and code in the cell, for example 401 unauthenticated.
| Status | Code | What to do |
|---|---|---|
| 401 | unauthenticated |
The key is wrong or revoked. Replace it in Script Properties. |
| 429 | See code |
You reached the per-minute limit or the monthly limit of your plan. Wait, or change plan. |
For a stock call you may also see 404 not_found for an id that matches no listing, and 404 not_covered when an exchange has no prices yet. Fix the key first, then reload the sheet.
Save your calls
Google Sheets can run a custom function again whenever the sheet reloads or an input changes, and one sheet can hold hundreds of them. Each run that reaches dino.markets counts as one request against your monthly limit.
The script saves each answer with CacheService for 300 seconds, which is the 300 in cache.put. During that time, every cell asking for the same ticker reads the saved price and uses no request. Raise it for a sheet you reload often, up to 21,600 seconds (6 hours).
A custom function must also finish within 30 seconds. If you track more than a few dozen stocks, call GET /v1/equities/prices once with up to 50 ids in ids instead. It counts as one request, however many ids you send.
Common questions
How many requests do I get
The Free plan has 3,000 successful requests a month. Starter has 20,000, Basic has 100,000 and Pro has 1,000,000. Failed requests do not count, and a batch request with up to 50 ids counts as one.
Can I try it before paying
Yes. Sign up for the Free plan, which needs no card.
Does the price update by itself
Not on a timer. A custom function runs when the sheet loads or when an input changes. To refresh on a schedule, use an Apps Script trigger that writes the prices into cells, and remember that each run counts against your monthly limit.
Is my key safe from people I share the sheet with
Viewers cannot open the script. Editors can, and they can also call the function, so share edit access only with people you trust. Make a key just for this sheet, and revoke it in the dashboard when you stop using it.
Why does the cell show a Loading message
The function is waiting for the answer. If it never ends, check that the key is saved in Script Properties and that the script was authorized.
Next steps
- Browse every endpoint in the stocks and funds reference.
- Prefer a script? Read stock prices in Python.
- Use Excel instead? Read stock prices in Excel.
Next steps
Start with a free key
3,000 requests a month, no card needed.