Free Forex API — Real-Time Exchange Rates & Historical Data
Live and historical FX rates for 1,300+ pairs across 140 world currencies and precious metals — 20+ years of history, updated at least once per minute, via one JSON API.
Twelve Data is a market-data API, not a broker — we deliver the rates; you build the product.
Start now Contact salesBroad FX coverage
1,300+ pairs across 140 currencies and precious metals.
Deep history
20+ years of historical exchange rates, down to intraday intervals.
Always current
Rates update at least once per minute, with tick-by-tick streaming available.
Free tier
Start with the free forex API plan, no credit card required.
Reliable forex data
Currency data is sourced from well established commercial providers and large banks, that correspond to the institutional grade performance standards.
Currency conversion
Apart from getting the single exchange rate data feed - you can also convert one currency to another with the specification of the amount.
Try the currency converterLow latency
Prices get updated at least once per minute depending on the currency pair. Higher intervals of data aggregation are available too.
Ease of integration
Set up JSON API in just a few minutes with a simple URL request or with the use of our SDKs & spreadsheets add-ins.
Forex data as is
Access 140 currencies and precious metals that make 1,300+ foreign exchange rates pairs updated in real time, with 20+ years of historical data - all that in a single API.
Major
Well-known currencies, with a large number of cross exchange rates.
- US Dollar (USD)
- Euro (EUR)
- Singapore Dollar (SGD)
- Korean Won (KRW)
- Australian Dollar (AUD)
- Swiss Franc (CHF)
- British Pound (GBP)
- Canadian Dollar (CAD)
- Chinese Yuan (CNY)
- Hong Kong Dollar (HKD)
- Indian Rupee (INR)
- Japanese Yen (JPY)
- New Zealand Dollar (NZD)
- Russian Ruble (RUB)
- Turkish Lira (TRY)
- UAE Dirham (AED)
- Argentinian Peso (ARS)
- Brazil Real (BRL)
- Central African CFA franc (XAF)
- Czech Koruna (CZK)
- Danish Krone (DKK)
- Icelandic Krona (ISK)
- Indonesian Rupiah (IDR)
- Israeli Shekel (ILS)
- Mexican Peso (MXN)
- Norwegian Krone (NOK)
- Qatari Riyal (QAR)
- Saudi Riyal (SAR)
- Thai Baht (THB)
Precious metals
- Brent Spot (XBR)
- Crude Oil WTI Spot (WTI)
- Gold Spot (XAU)
- Gold Gram (GAU)
- Silver Spot (XAG)
- Gram Silver (XAGg)
- Palladium Spot (XPD)
- Platinum Spot (XPT)
- Copper Pound (XG)
Minor
Foreign exchange rates from all 5 continents that also update in real-time, including the exotic ones.
- Afghanistan Afghani (AFN)
- Albanian Lek (ALL)
- Algerian Dinar (DZD)
- Angolan kwanza (AOA)
- Antilles Guilder (ANG)
- Armenian Dram (AMD)
- Azerbaijani Manat (AZN)
- Bahamas Dollar (BSD)
- Baharain Dinar (BHD)
- Bangladeshi Taka (BDT)
- Barbadian Dollar (BBD)
- Belarusian Ruble (BYN)
- Belize Dollar (BZD)
- Bolivian Boliviano (BOB)
- Bosnia-Herzegovina Convertible Mark (BAM)
- Botswana Pula (BWP)
- Brunei Dollar (BND)
- Bulgarian Lev (BGN)
- Burundian Franc (BIF)
- Cambodian Riel (KHR)
- Cape Verdean Escudo (CVE)
- Cayman Islands Dollar (KYD)
- Costa Rican Colon (CRC)
- Croatian Kuna (HRK)
- Cuban Peso (CUP)
- Chilean Peso (CLP)
- Colombian Peso (COP)
- Djiboutian Franc (DJF)
- Dominican Peso (DOP)
- El Salvador Colon (SVC)
- Ethiopian Birr (ETB)
- East Caribbean Dollar (XCD)
- Egyptian Pound (EGP)
- Fiji Dollar (FJD)
- French Pacific Franc (XPF)
- Gambian Dalasi (GMD)
- Georgian lari (GEL)
- Haitian Gourde (HTG)
- Honduran Lempira (HNL)
- Hungarian Forint (HUF)
- Iranian Rial (IRR)
- Iraqi Dinar (IQD)
- Jordan Dinar (JOD)
- Jamaican Dollar (JMD)
- Kazakh Tenge (KZT)
- Kenyan Shilling (KES)
- Kuwaiti Dinar (KWD)
- Kyrgyzstan som (KGS)
- Lebanese Pound (LBP)
- Macedonian Denar (MKD)
- Malawian Kwacha (MWK)
- Malaysian Ringgit (MYR)
- Mauritian Rupee (MUR)
- Mongolian Tugrik (MNT)
- Moroccan Dirham (MAD)
- Namibian Dollar (NAD)
- Nepalese Rupee (NPR)
- Nicaraguan Cordoba (NIO)
- Nigerian Naira (NGN)
- Omani Rial (OMR)
- Pakistani Rupee (PKR)
- Panamanian Balboa (PAB)
- Papua New Guinean kina (PGK)
- Paraguayan Guarani (PYG)
- Peru Sol (PEN)
- Philippine Peso (PHP)
- Polish Zloty (PLN)
- Romanian Leu (RON)
- Sao Tomean Dobra (STD)
- Serbian Dinar (RSD)
- Sri Lankan Rupee (LKR)
- Sudanese Pound (SDG)
- Syrian Pound (SYP)
- Taiwan Dollar (TWD)
- Tajikistani somoni (TJS)
- Turkmenistan manat (TMT)
- Tunisian Dinar (TND)
- Iraqi Dinar (IQD)
- Ukrainian Hryvnia (UAH)
- Uruguayan Peso (UYU)
- Uzbekistani Sum (UZS)
- Venezuelan Bolivar (VEF)
- West African CFA franc (XOF)
- Vietnamese Dong (VND)
- Special Drawing Rights (SDR)
Developer-centric
Rapidly integrate our currency exchange data into your project with modern languages, from Python to Golang. Using Twelve Data's API means less code maintenance and more time towards building a great product.
- Simple forex documentation
- Highly accurate rates with low response latency
- Institutional-level security with 256-bit SSL encryption
- Lightweight JSON & CSV formats
- 99.95% uptime SLA (99.99% on Enterprise)
curl "https://api.twelvedata.com/exchange_rate?symbol=EUR/USD&apikey=your_api_key"
- from twelvedata import TDClient
- td = TDClient(apikey="YOUR_API_KEY_HERE")
- ts = td.time_series(
- symbol="TSLA",
- interval="1min",
- outputsize=12,
- )
- print(ts.as_json())
- #include <cjson/cJSON.h> // https://github.com/DaveGamble/cJSON
- #include <curl/curl.h>
- #include <iostream>
- #include <memory>
- const char* REQUEST_URL = "https://api.twelvedata.com/time_series?symbol=TSLA&interval=1min&outputsize=12&apikey=YOUR_API_KEY_HERE";
- // Take response data and write into the string
- std::size_t write_callback(const char* data, std::size_t size, std::size_t count, std::string* out) {
- const std::size_t result = size * count;
- out->append(data, result);
- return result;
- }
- int main() {
- std::unique_ptr<std::string> responseData(new std::string());
- cJSON* json = nullptr;
- CURL* curl = curl_easy_init();
- curl_easy_setopt(curl, CURLOPT_URL, REQUEST_URL);
- curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
- curl_easy_setopt(curl, CURLOPT_WRITEDATA, responseData.get());
- curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
- curl_easy_perform(curl);
- json = cJSON_Parse(responseData->c_str());
- cJSON* metaField = cJSON_GetObjectItem(json, "meta");
- cJSON* valuesField = cJSON_GetObjectItem(json, "values");
- cJSON* symbolField = cJSON_GetObjectItem(metaField, "symbol");
- cJSON* closeField = cJSON_GetObjectItem(cJSON_GetArrayItem(valuesField, 0), "close");
- std::cout << "Received symbol: " << cJSON_GetStringValue(symbolField) << ", ";
- std::cout << "close: " << cJSON_GetStringValue(closeField) << std::endl;
- cJSON_Delete(json);
- curl_easy_cleanup(curl);
- return 0;
- }
- using System;
- using System.Collections.Generic;
- using System.Net;
- using System.Text.Json;
- namespace TwelveData
- {
- public class TimeSeries
- {
- public Dictionary<string, string> meta { get; set; }
- public IList<Dictionary<string, string>> values { get; set; }
- public string status { get; set; }
- }
- class Prices
- {
- static void Main(string[] args)
- {
- var response = wc.DownloadString("https://api.twelvedata.com/time_series?symbol=TSLA&interval=1min&outputsize=12&apikey=YOUR_API_KEY_HERE");
- var timeSeries = JsonSerializer.Deserialize<TimeSeries>(response);
- if (timeSeries.status == "ok")
- {
- Console.WriteLine("Received symbol: " + timeSeries.meta["symbol"] + ", close: " + timeSeries.values[0]["close"]);
- }
- }
- }
- }
- import org.json.simple.parser.JSONParser;
- import org.json.simple.JSONArray;
- import org.json.simple.JSONObject;
- import java.util.Scanner;
- import java.net.HttpURLConnection;
- import java.net.URL;
- public class Main {
- private static final String REQUEST_URL = "https://api.twelvedata.com/time_series?symbol=TSLA&interval=1min&outputsize=12&apikey=YOUR_API_KEY_HERE";
- JSONParser parser = new JSONParser();
- connection.setRequestMethod("GET");
- connection.setRequestProperty("User-Agent", "twelve_java/1.0");
- connection.connect();
- if (connection.getResponseCode() != 200) {
- }
- Scanner scanner = new Scanner(requestURL.openStream());
- while (scanner.hasNextLine()) {
- responseData.append(scanner.nextLine());
- }
- JSONObject json = (JSONObject) parser.parse(responseData.toString());
- JSONObject meta = (JSONObject) json.get("meta");
- JSONArray values = (JSONArray) json.get("values");
- connection.disconnect();
- }
- }
- # install.packages("RcppSimdJson")
- apikey <- "YOUR_API_KEY_HERE"
- qry <- paste0(
- "https://api.twelvedata.com/time_series?",
- "symbol=AAPL&interval=1min&outputsize=12",
- "&apikey=", apikey)
- res <- RcppSimdJson::fload(qry)
- res
- # pip install twelvedata[websocket]
- from twelvedata import TDClient
- def on_event(e):
- print(e)
- td = TDClient(apikey="YOUR_API_KEY_HERE")
- ws = td.websocket(symbols="TSLA", on_event=on_event)
- ws.connect()
- ws.keep_alive()
- #include <websocketpp/config/asio_client.hpp>
- #include <websocketpp/client.hpp>
- #include <cjson/cJSON.h>
- #include <iostream>
- #include <iomanip>
- #include <ctime>
- namespace wlib = websocketpp::lib;
- namespace ssl = boost::asio::ssl;
- typedef websocketpp::client<websocketpp::config::asio_tls_client> wclient;
- typedef wlib::shared_ptr<wlib::asio::ssl::context> context_ptr;
- const char* ENDPOINT = "wss://ws.twelvedata.com/v1/quotes/price?apikey=YOUR_API_KEY_HERE";
- const char* SUBSCRIBE_ACTION = "{"\
- "\"action\": \"subscribe\"," \
- "\"params\": {" \
- "\"symbols\": \"TSLA\"" \
- "}" \
- "}";
- int main() {
- wclient::connection_ptr connection;
- wlib::error_code error_code;
- wclient client;
- client.set_access_channels(websocketpp::log::alevel::all);
- client.clear_access_channels(websocketpp::log::alevel::frame_payload);
- client.set_error_channels(websocketpp::log::elevel::all);
- // Initialize Boost.ASIO
- client.init_asio();
- // Set TLS initialize handler
- client.set_tls_init_handler(wlib::bind([](auto* hostname, auto hdl) {
- context_ptr context = wlib::make_shared<ssl::context>(ssl::context::sslv23);
- context->set_verify_mode(ssl::verify_none);
- return context;
- }, ENDPOINT, websocketpp::lib::placeholders::_1));
- // Is called after the WebSocket handshake is complete
- client.set_open_handler([&client](auto hdl) {
- // Send subscribe action to stream
- client.send(hdl, SUBSCRIBE_ACTION, websocketpp::frame::opcode::text);
- });
- // Receive and handle messages from server
- client.set_message_handler([](auto hdl, wclient::message_ptr message) {
- cJSON* json = cJSON_Parse(message->get_payload().c_str());
- if (json == nullptr) {
- std::cout << "received invalid JSON: " << std::endl << message->get_payload() << std::endl;
- return;
- }
- // Get event type
- cJSON* eventTypeField = cJSON_GetObjectItem(json, "event");
- if (eventTypeField == nullptr) {
- std::cout << "unknown JSON structure" << std::endl;
- return;
- }
- // Extract string from event type
- const char* eventType = cJSON_GetStringValue(eventTypeField);
- if (strcmp(eventType, "subscribe-status") == 0) {
- cJSON* statusField = cJSON_GetObjectItem(json, "status");
- const char* status = cJSON_GetStringValue(statusField);
- if (strcmp(status, "ok") != 0) {
- std::cout << "Failed subscribe to stream" << std::endl;
- return;
- }
- cJSON* successField = cJSON_GetObjectItem(json, "success");
- cJSON* failsField = cJSON_GetObjectItem(json, "fails");
- // Iterate over the symbols that were successfully subscribed
- for (int idx = 0; idx < cJSON_GetArraySize(successField); idx++) {
- cJSON* item = cJSON_GetArrayItem(successField, idx);
- cJSON* symbolField = cJSON_GetObjectItem(item, "symbol");
- const char* symbol = cJSON_GetStringValue(symbolField);
- std::cout << "Success subscribed to `"<< symbol << "` " << "symbol." << std::endl;
- }
- // If we're unable to subscribe to some symbols
- for (int idx = 0; 0 < cJSON_GetArraySize(failsField); idx++) {
- cJSON* item = cJSON_GetArrayItem(failsField, idx);
- cJSON* symbolField = cJSON_GetObjectItem(item, "symbol");
- const char* symbol = cJSON_GetStringValue(symbolField);
- std::cout << "Failed to subscribe on `"<< symbol << "` " << "symbol." << std::endl;
- }
- return;
- }
- if (strcmp(eventType, "price") == 0) {
- cJSON* timestampField = cJSON_GetObjectItem(json, "timestamp");
- cJSON* currencyField = cJSON_GetObjectItem(json, "currency");
- cJSON* symbolField = cJSON_GetObjectItem(json, "symbol");
- cJSON* priceField = cJSON_GetObjectItem(json, "price");
- time_t time = timestampField->valueint;
- std::cout << "[" << std::put_time(gmtime(&time), "%I:%M:%S %p") << "]: ";
- std::cout << "The symbol `" << cJSON_GetStringValue(symbolField) << "` ";
- std::cout << "has changed price to " << priceField->valuedouble << " ";
- if (currencyField != nullptr) {
- std::cout << "(" << cJSON_GetStringValue(currencyField) << ")" << std::endl;
- } else {
- std::cout << std::endl;
- }
- return;
- }
- // Free memory of JSON structure
- cJSON_Delete(json);
- });
- // New connection to WebSocket endpoint
- connection = client.get_connection(ENDPOINT, error_code);
- if (error_code) {
- std::cout << "Failed connection. Message: " << error_code.message() << std::endl;
- return -1;
- }
- // Connect to websocket endpoint
- client.connect(connection);
- client.run();
- }
- using System;
- using WebSocket4Net; //https://github.com/kerryjiang/WebSocket4Net
- namespace TwelveData
- {
- class TDWebSocket
- {
- static void Main()
- {
- }
- public void Init()
- {
- ws.Opened += OnOpen;
- ws.Closed += OnClose;
- ws.Error += OnError;
- ws.MessageReceived += OnEvent;
- ws.Open();
- Console.ReadLine();
- }
- private void OnOpen(object sender, EventArgs e)
- {
- Console.WriteLine("TDWebSocket opened!");
- ws.Send("{\"action\": \"subscribe\", \"params\":{\"symbols\": \"TSLA\"}}");
- }
- private void OnClose(object sender, EventArgs e)
- {
- Console.WriteLine("TDWebSocket closed");
- }
- private void OnError(object sender, SuperSocket.ClientEngine.ErrorEventArgs e)
- {
- Console.WriteLine("TDWebSocket ERROR: " + e.Exception.Message);
- }
- private void OnEvent(object sender, MessageReceivedEventArgs e)
- {
- Console.WriteLine(e.Message);
- }
- }
- }
- import org.java_websocket.handshake.ServerHandshake;
- import org.java_websocket.client.WebSocketClient;
- import org.json.simple.parser.ParseException;
- import org.json.simple.parser.JSONParser;
- import org.json.simple.JSONObject;
- import java.net.URI;
- public class Main {
- private static final String ENDPOINT = "wss://ws.twelvedata.com/v1/quotes/price?apikey=YOUR_API_KEY_HERE";
- WebSocketClient client = new WebSocketClient(new URI(ENDPOINT)) {
- @Override
- public void onOpen(ServerHandshake handshake) {
- send("{\"action\": \"subscribe\", \"params\":{\"symbols\": \"TSLA\"}}");
- }
- @Override
- JSONParser parser = new JSONParser();
- try {
- JSONObject json = (JSONObject) parser.parse(message);
- e.printStackTrace();
- }
- }
- @Override
- this.close();
- }
- @Override
- e.printStackTrace();
- }
- };
- client.connectBlocking();
- }
- }
- # install.packages("websocket")
- ws <- WebSocket$new("wss://ws.twelvedata.com/v1/quotes/price?apikey=YOUR_API_KEY_HERE")
- })
- " and reason ", event$reason, "\n", sep = "")
- })
- })
- })
- ws$send('{"action": "subscribe", "params":{"symbols": "TSLA"}}')
Create powerful forex applications
Search
Easily add a lookup of any symbol into your app with the most effective search in the industry.
ExploreTechnical indicators
Extensive collection of indicators, ready to be used for technical analysis.
ExploreHighly scalable
Suitable from single-user apps to highly loaded systems with thousands of users.
ExploreInstitutional grade infrastructure. Designed to scale.
Curious, but not a developer?
We love our products and the way it empowers new stories.
We can help you to build projects of
any difficulty, to deliver the highest quality.
FAQ
Questions? Answers.
Ready to get started? Get in touch or create an account.
Access the world currency exchange rates with the forex data API.
Start now Contact sales