Crypto Price API in Google Sheets: A Trader's Guide
A practical guide to connecting crypto price APIs to Google Sheets. Learn to track live prices from Binance, CoinGecko, and more with real code examples.
A practical guide to connecting crypto price APIs to Google Sheets. Learn to track live prices from Binance, CoinGecko, and more with real code examples.
Google Sheets combined with a crypto price API is one of the most underrated setups in a trader's toolkit. Whether you're tracking positions across Binance, Bybit, and OKX, or monitoring 30 altcoins at once, pulling live prices directly into a spreadsheet gives you flexibility that no pre-built dashboard can match. No subscription fees, no arbitrary limitations — just raw data flowing exactly where you need it.
Most crypto apps show you what they want you to see. Google Sheets shows you what you need to see. You control the layout, the formulas, the conditional alerts — everything. Combined with crypto prices google sheets integration through an API, you get a fully custom analytics environment built around your actual trading strategy rather than some product team's assumptions.
The setup has three layers: the API source (where prices come from), the connection layer (how they get into your sheet), and the dashboard (how you display and analyze them). We'll cover all three with working code.
The fastest way to pull crypto prices into Google Sheets without leaving the browser is Google Apps Script — it's JavaScript that runs natively inside your spreadsheet. No servers, no installations, no external dependencies. Open your spreadsheet, go to Extensions → Apps Script, paste the code below, and you're live.
function getCryptoPrice(coinId) {
var url = 'https://api.coingecko.com/api/v3/simple/price?ids=' + coinId + '&vs_currencies=usd&include_24hr_change=true';
var response = UrlFetchApp.fetch(url);
var data = JSON.parse(response.getContentText());
return data[coinId]['usd'];
}
function updateCryptoPrices() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var coins = [
['bitcoin', 'BTC'],
['ethereum', 'ETH'],
['solana', 'SOL'],
['binancecoin', 'BNB']
];
for (var i = 0; i < coins.length; i++) {
try {
var price = getCryptoPrice(coins[i][0]);
sheet.getRange(i + 2, 1).setValue(coins[i][1]);
sheet.getRange(i + 2, 2).setValue(price);
sheet.getRange(i + 2, 3).setValue(new Date());
} catch (e) {
sheet.getRange(i + 2, 2).setValue('API Error: ' + e.message);
}
}
}
// Run updateCryptoPrices() once manually to authorize, then call this
function createTimeTrigger() {
ScriptApp.newTrigger('updateCryptoPrices')
.timeBased()
.everyMinutes(5)
.create();
}
Run updateCryptoPrices() once manually to grant authorization. After that, call createTimeTrigger() once to set up automatic 5-minute refreshes. Your sheet will now update silently in the background, even when you're not looking at it.
If you prefer Python — or you want to push data into Google Sheets from an external script via the Sheets API — CoinGecko's free tier is the standard starting point. It requires zero authentication for basic price queries and covers every major coin listed on Coinbase, Binance, Gate.io, and KuCoin. The endpoint is stable, well-documented, and the response format is consistent.
import requests
def get_crypto_prices(coin_ids, currency='usd'):
url = 'https://api.coingecko.com/api/v3/simple/price'
params = {
'ids': ','.join(coin_ids),
'vs_currencies': currency,
'include_24hr_change': 'true',
'include_market_cap': 'true'
}
try:
response = requests.get(url, params=params, timeout=10)
response.raise_for_status()
return response.json()
except requests.exceptions.Timeout:
print('Request timed out — CoinGecko may be rate limiting you')
return {}
except requests.exceptions.HTTPError as e:
print('HTTP error: ' + str(e))
return {}
coins = ['bitcoin', 'ethereum', 'solana', 'binancecoin', 'ripple']
prices = get_crypto_prices(coins)
for coin, data in prices.items():
price = data.get('usd', 0)
change = data.get('usd_24h_change', 0)
mcap = data.get('usd_market_cap', 0)
print(
coin + ': $' + str(round(price, 4)) +
' | 24h: ' + str(round(change, 2)) + '%' +
' | MCap: $' + str(round(mcap / 1e9, 2)) + 'B'
)
The free CoinGecko tier allows 30 requests per minute. For portfolio tracking that's plenty — you're pulling snapshots, not streaming a feed. If you do hit the limit, add a small time.sleep(2) between batched calls. The Pro tier unlocks 500 calls/minute if you scale up.
When you need more than spot prices — actual account balances, order history, real-time order book depth — the Binance API goes deeper. Public endpoints (price, klines, 24h stats) require zero authentication. Private endpoints need an API key generated from your Binance account under Settings → API Management.
import hmac
import hashlib
import time
import requests
import os
API_KEY = os.environ.get('BINANCE_API_KEY', '')
SECRET_KEY = os.environ.get('BINANCE_SECRET_KEY', '')
BASE_URL = 'https://api.binance.com'
def get_price(symbol):
url = BASE_URL + '/api/v3/ticker/price'
response = requests.get(url, params={'symbol': symbol}, timeout=10)
response.raise_for_status()
return float(response.json()['price'])
def get_24h_stats(symbol):
url = BASE_URL + '/api/v3/ticker/24hr'
response = requests.get(url, params={'symbol': symbol}, timeout=10)
response.raise_for_status()
return response.json()
def signed_request(endpoint, params=None):
if params is None:
params = {}
params['timestamp'] = int(time.time() * 1000)
query = '&'.join([str(k) + '=' + str(v) for k, v in params.items()])
sig = hmac.new(
SECRET_KEY.encode('utf-8'),
query.encode('utf-8'),
hashlib.sha256
).hexdigest()
headers = {'X-MBX-APIKEY': API_KEY}
url = BASE_URL + endpoint + '?' + query + '&signature=' + sig
return requests.get(url, headers=headers, timeout=10).json()
# Public endpoints — no auth needed
print('BTC/USDT: $' + str(get_price('BTCUSDT')))
print('ETH/USDT: $' + str(get_price('ETHUSDT')))
stats = get_24h_stats('SOLUSDT')
print('SOL 24h high: $' + stats['highPrice'])
print('SOL 24h volume: ' + str(round(float(stats['volume']), 2)))
# Private endpoint — requires valid API key and secret
account = signed_request('/api/v3/account')
non_zero = [b for b in account.get('balances', []) if float(b['free']) > 0]
for b in non_zero:
print(b['asset'] + ': ' + b['free'])
Security rule: never hardcode API keys in your script. Load them from environment variables or a .env file and never commit secrets to git. On Binance, restrict your API key to read-only access unless you explicitly need trading permissions — this limits blast radius if a key ever leaks.
With live prices flowing in through Apps Script, the next step is structuring a dashboard that calculates your full P&L automatically. Here's the column layout that works cleanest for active traders holding positions across multiple exchanges.
| Column | Formula / Source | Purpose |
|---|---|---|
| A: Asset | Manual entry | Ticker symbol (BTC, ETH, SOL) |
| B: Price (USD) | Apps Script live fetch | Refreshed every 5 minutes |
| C: Holdings | Manual entry | Number of coins held |
| D: Value (USD) | =B2*C2 | Current position value in USD |
| E: Avg Buy Price | Manual entry | Your cost basis per coin |
| F: P&L (USD) | =(B2-E2)*C2 | Unrealized profit or loss |
| G: P&L (%) | =(B2-E2)/E2*100 | Percentage gain or loss |
| H: Exchange | Manual entry | Where the position is held |
Add a SUM row at the bottom of columns D and F to see total portfolio value and total unrealized P&L in one glance. Apply conditional formatting to column G — green background for positive values, red for negative — and you have a visual risk monitor. For the Exchange column, being specific matters: knowing your ETH sits on Bybit while your SOL is on OKX helps you spot liquidity concentration risk if one platform has issues.
For traders who want signal intelligence layered on top of raw price data, VoiceOfChain delivers real-time trading signals you can cross-reference against your portfolio sheet. When a coin you're holding starts generating unusual signal activity, knowing before the price move completes is the entire edge.
A crypto price API connected to Google Sheets gives you a level of control over your portfolio data that no off-the-shelf dashboard can replicate. Start with the Apps Script setup for zero-friction live prices, add Python scripts when you need more power, and layer exchange-specific data from Binance, Bybit, or OKX as your tracking needs grow. The infrastructure is free, the flexibility is unlimited, and once the setup is done it runs quietly in the background while you focus on trading.