Twelve Data Connector
Building forex charts (EUR/USD, GBP/USD) or multi-asset fintech apps? The Twelve Data connector wraps the Twelve Data API and implements the same DataAdapter contract as Binance and Kraken.
Use the controls above to switch forex pair and timeframe. This docs demo routes requests through /api/twelve-data so your API key stays on the server.
Full-page version with sample code: Twelve Data live demo.
Unlike public crypto connectors, Twelve Data requires an API key in production. Store it in TWELVE_DATA_API_KEY and run the adapter on your server or behind a proxy — never ship the key in a browser bundle. The docs demo uses a server-side proxy (defaults to Twelve Data demo key when unset).
What you get
| Feature | Details |
|---|---|
| Forex | Majors, minors, exotics (EUR/USD, USD/JPY, …) |
| Multi-asset | Same API also covers stocks, crypto, ETFs |
| History | OHLCV via /time_series |
| Live ticks | WebSocket price stream |
| Symbols | Accepts EUR/USD, EUR-USD, EURUSD |
Perfect for forex dashboards, wealth apps, and multi-asset prototypes.
Twelve Data vs crypto connectors
| Twelve Data | Binance / Kraken | |
|---|---|---|
| Asset class | Forex, stocks, crypto | Crypto spot |
| API key | Required | Not required (public endpoints) |
| Live transport | WebSocket | WebSocket |
| Best for | FX + multi-asset backends | Browser crypto charts |
Licensing
| Tier | Typical use |
|---|---|
| Free / Basic | Development, personal testing |
| Paid | Production apps with external display |
Free tiers are not a substitute for a production license when end users see the data. Check Twelve Data pricing and attribution guidelines.
Install
npm install @efixdata/exeria-chart @efixdata/connector-twelve-data
Minimal example (Node.js)
import { createChart } from "@efixdata/exeria-chart";
import { TwelveDataAdapter } from "@efixdata/connector-twelve-data";
const connector = new TwelveDataAdapter({
apiKey: process.env.TWELVE_DATA_API_KEY!,
});
const chart = createChart({
container,
dataAdapter: connector,
});
chart.init();
await chart.loadData("EUR/USD", {
interval: "1h",
limit: 500,
});
chart.subscribeToUpdates("EUR/USD", (tick) => {
console.log("Last price:", tick.price ?? tick.c);
});
Step by step
1 — Get an API key
Sign up at twelvedata.com, generate a key, and store it securely:
export TWELVE_DATA_API_KEY=your_key_here
2 — Create the connector
const connector = new TwelveDataAdapter({
apiKey: process.env.TWELVE_DATA_API_KEY!,
});
3 — Attach to the chart
const chart = createChart({ container, dataAdapter: connector });
chart.init();
4 — Load history
await chart.loadData("EUR/USD", {
interval: "1h",
limit: 500,
});
| Option | Meaning |
|---|---|
interval | "1m", "1h", "1d", "1w", "1M" (mapped to Twelve Data intervals) |
limit | Recent N candles (outputsize, max 5000) |
from / to | Optional ISO date range |
5 — Go live
chart.subscribeToUpdates("EUR/USD");
Uses Twelve Data WebSocket price events. On free tiers, WebSocket symbol limits may apply.
6 — Clean up
chart.unsubscribeFromUpdates();
await connector.disconnect();
Popular forex symbols
| Symbol | Market |
|---|---|
EUR/USD | Euro / US Dollar |
GBP/USD | British Pound / US Dollar |
USD/JPY | US Dollar / Japanese Yen |
USD/CHF | US Dollar / Swiss Franc |
AUD/USD | Australian Dollar / US Dollar |
Compact forms (EURUSD, EUR-USD) are normalized automatically.
Next.js API route (browser-safe pattern)
// app/api/forex/ohlcv/route.ts
import { TwelveDataAdapter } from "@efixdata/connector-twelve-data";
import { NextResponse } from "next/server";
const connector = new TwelveDataAdapter({
apiKey: process.env.TWELVE_DATA_API_KEY!,
});
export async function GET(request: Request) {
const { searchParams } = new URL(request.url);
const symbol = searchParams.get("symbol") ?? "EUR/USD";
const interval = searchParams.get("interval") ?? "1h";
const limit = Number(searchParams.get("limit") ?? "500");
await connector.initialize({});
const candles = await connector.getHistoricalData(symbol, { interval, limit });
return NextResponse.json({ candles });
}
Your frontend can call /api/forex/ohlcv or wrap responses in a custom DataAdapter that proxies your API.
Configuration
const connector = new TwelveDataAdapter({
apiKey: process.env.TWELVE_DATA_API_KEY!,
baseUrl: "https://api.twelvedata.com",
wsUrl: "wss://ws.twelvedata.com/v1/quotes/price",
requestTimeout: 10000,
maxRetries: 3,
onError: (error) => console.error("Twelve Data error:", error),
});
Limits to know
| Topic | Limit |
|---|---|
| API credits | Plan-specific; /time_series costs more than /price |
| Rate limits | Free tier is low (~8 req/min); cache history server-side |
| Forex hours | Market trades 24/5; weekend shows last available quote |
| Browser | Use a backend proxy; do not expose apiKey client-side |
| WebSocket | Paid plans unlock more concurrent symbols |
What is next?
- Overview — connector lifecycle
- Binance · Kraken · KuCoin — public crypto connectors
- CCXT — many crypto exchanges via one package
- Connect with a Data Connector — tutorial walkthrough
- Data Connectors catalog — compare providers