Bloomberg terminal costs $24,000/year. These 7 free APIs give you most of the data you actually need.
1. Yahoo Finance — Stock Data (No Key)
import requests
def get_stock(symbol):
url = f'https://query1.finance.yahoo.com/v8/finance/chart/{symbol}'
resp = requests.get(url, headers={'User-Agent': 'Mozilla/5.0'},
params={'interval': '1d', 'range': '5d'})
meta = resp.json()['chart']['result'][0]['meta']
price = meta['regularMarketPrice']
prev = meta['previousClose']
change = price - prev
print(f"${symbol}: ${price:.2f} ({'+' if change>0 else ''}{change:.2f})")
get_stock('AAPL') # Apple
get_stock('TSLA') # Tesla
get_stock('NVDA') # NVIDIA
No key needed. Real-time-ish data.
2. CoinGecko — Crypto Prices (No Key)
10,000+ coins with market cap, volume, and 24h change.
def get_crypto(coins=['bitcoin','ethereum','solana']):
resp = requests.get('https://api.coingecko.com/api/v3/simple/price', params={
'ids': ','.join(coins),
'vs_currencies': 'usd',
'include_24hr_change': 'true'
})
for coin, data in resp.json().items():
print(f"{coin}: ${data['usd']:,.2f} ({data.get('usd_24h_change',0):+.1f}%)")
get_crypto()
3. Exchange Rate API — Forex (No Key)
150+ currencies, updated daily.
def forex(base='USD'):
resp = requests.get(f'https://open.er-api.com/v6/latest/{base}')
rates = resp.json()['rates']
for currency in ['EUR', 'GBP', 'JPY', 'CHF']:
print(f"1 {base} = {rates[currency]} {currency}")
forex('USD')
4. FRED — Economic Indicators (Free Key)
The Federal Reserve's data API. GDP, unemployment, inflation, interest rates.
FRED_KEY = 'your_free_key' # fred.stlouisfed.org
def get_indicator(series_id, name):
resp = requests.get('https://api.stlouisfed.org/fred/series/observations', params={
'series_id': series_id, 'api_key': FRED_KEY,
'file_type': 'json', 'sort_order': 'desc', 'limit': 3
})
for obs in resp.json().get('observations', []):
print(f"{name}: {obs['value']} ({obs['date']})")
get_indicator('UNRATE', 'Unemployment')
get_indicator('CPIAUCSL', 'CPI')
5. Alpha Vantage — Fundamentals (Free Key)
Earnings, balance sheets, income statements.
AV_KEY = 'your_free_key' # alphavantage.co
def get_earnings(symbol):
resp = requests.get('https://www.alphavantage.co/query', params={
'function': 'EARNINGS', 'symbol': symbol, 'apikey': AV_KEY
})
for q in resp.json().get('quarterlyEarnings', [])[:4]:
print(f"{q['fiscalDateEnding']}: EPS ${q['reportedEPS']} (est: ${q['estimatedEPS']})")
get_earnings('AAPL')
6. IEX Cloud — Market Data (Free Tier)
Real-time quotes, news, and company data.
7. Finnhub — Stock News & Sentiment (Free Key)
Company news, sentiment analysis, insider transactions.
FH_KEY = 'your_free_key' # finnhub.io
def get_news(symbol):
from datetime import datetime, timedelta
today = datetime.now().strftime('%Y-%m-%d')
week_ago = (datetime.now() - timedelta(days=7)).strftime('%Y-%m-%d')
resp = requests.get('https://finnhub.io/api/v1/company-news', params={
'symbol': symbol, 'from': week_ago, 'to': today, 'token': FH_KEY
})
for article in resp.json()[:5]:
print(f" {article['headline'][:70]}")
print(f" Source: {article['source']}\n")
get_news('TSLA')
Build a Dashboard
def market_snapshot():
print("=== Stocks ===")
for s in ['AAPL', 'GOOGL', 'MSFT', 'TSLA', 'NVDA']:
get_stock(s)
print("\n=== Crypto ===")
get_crypto(['bitcoin', 'ethereum', 'solana'])
print("\n=== Forex ===")
forex('USD')
market_snapshot()
Full toolkit: finance-api-toolkit
What financial data API do you use? Any hidden gems I should add to the toolkit?
More tools: Apify scrapers | GitHub
Top comments (0)