Twelve Data API
Stock, forex, crypto and ETF data with real-time and historical time series.
What it does
Twelve Data provides real-time and historical prices for stocks, forex, crypto, ETFs and indices, plus technical indicators, fundamentals, earnings and a WebSocket stream. Coverage is global, and the free tier is comparatively generous.
Base URL
Authentication
Sign up for a free API key and pass it as &apikey=YOUR_KEY (or the Authorization: apikey YOUR_KEY header). Endpoints are RESTful: /price, /quote, /time_series, /exchange_rate.
Code examples
curl -s "https://api.twelvedata.com/time_series?symbol=AAPL&interval=1day&outputsize=5&apikey=$TD_KEY"
import requests
r = requests.get("https://api.twelvedata.com/quote",
params={"symbol": "TSLA", "apikey": KEY}, timeout=10)
q = r.json()
if q.get("status") == "error":
raise SystemExit(q["message"])
print(q["name"], q["close"], q["percent_change"])Rate limits & quotas
Free plan: 800 API credits/day and 8 requests/minute. Most calls cost 1 credit; batch or multi-symbol and some heavy endpoints cost more. Over the minute limit returns {"status":"error","code":429}. WebSocket and some fundamentals are paid-only.
Key response fields
| price | Latest price (/price) |
| close / percent_change / is_market_open | From /quote |
| values[] | Time-series rows: datetime, open, high, low, close, volume |
| status | ok or error (with code + message) |
| meta | Symbol, exchange, currency, interval |
Common errors
| code 401 | Invalid API key. |
| code 429 | Per-minute (8) or per-day (800 credits) limit exceeded. |
| code 404 | Symbol not found — use /symbol_search or add an exchange suffix. |
| code 400 | Missing/invalid parameter such as interval. |
When to use it (and alternatives)
A strong free default for global quotes and candlestick data. Compare Finnhub (higher per-minute rate, US-focused free tier) and Polygon.io (EOD-only free but excellent data quality).
FAQ
What is an 'API credit'?
Twelve Data meters usage in credits, not raw requests. A single-symbol quote is 1 credit; asking for many symbols or a large technical-indicator series costs more. The daily budget is 800 credits.
Does the free tier include real-time prices?
Real-time and delayed quotes are available for many markets on free, but some exchanges require a paid data plan for real-time. The /quote response tells you the quote’s timeliness.
How do I reference a non-US stock?
Use symbol=BMW&exchange=XETR or the dotted form symbol=BMW.DE. /symbol_search returns the exact codes.
New to APIs?
Short guides for working with this API — and any other.