Welcome to Tradermade. We provide clean forex and CFD data via easy to use delivery methods. We use HTTPS and RESTful structure
which makes it easier to request data. Authentication is over a secure HTTPS protocol and responses are in JSON Format.
Following are a few simple steps to start getting data.
Quick Start Guide
We have created a number of tutorials to help you get started with our REST API. Our tutorials cover topics such as Excel, Python, C#, etc.
Authentication
You need to include your API key with each request to get data. You can find your api key under your account once you login.
You can run sample API queries from this page once you login. You can also learn more on how to use our forex data API on the tutorials page
Python SDK
pip install tradermade
Python users can simply install our SDK to start using our API in seconds. We recommend going through our python SDK documentation. Alternatively, you can read our tutorial on how to use our Python-SDK for Forex Data
import tradermade as tm
# set api key
tm.set_rest_api_key("api_key")
#get data
tm.live(currency='EURUSD,GBPUSD',fields=["bid", "mid", "ask"]) # returns live data - fields is optional
tm.historical(currency='EURUSD,GBPUSD', date="2021-04-22",interval="daily", fields=["open", "high", "low","close"]) # returns historical data for the currency requested interval is daily, hourly, minute - fields is optional
tm.timeseries(currency='EURUSD', start="2021-04-20",end="2021-04-22",interval="hourly",fields=["open", "high", "low","close"]) # returns timeseries data for the currency requested interval is daily, hourly, minute - fields is optional
tm.cfd_list() # gets list of all cfds available
tm.currency_list() # gets list of all currency codes available add two codes to get code for currencypair ex EUR + USD gets EURUSD
Supported Currencies
We support over 8000+ currency pairs on our api endpoints. This includes 4000+ cryptocurrency pairs. A list of Forex and Crypto codes for live endpoint can be accessed by visting our
live currencies list page. We also have CFDs, Visit CFD list page for codes. You can also see below the full CFD list we provide:
Commodities: Copper, OIL (US), UKOIL, NATGAS
Indices: USDX (USD Index), UK100 (FTSE), SPX500, FRA40 (CAC), GER30 (DAX), JPN225 (Nikkei), NAS100 (Nasdaq), USA30 (Dow), HKG33 (Hang Seng), AUS200
Equities: AAPL, FB, AMZN, NFLX, TSLA, GOOGL, BABA, TWTR, BAC, BIDU
Live Currencies List
A list of the available currencies for the /live and the /convert endpoint, can be accessed through requesting the live_currencies_list endpoint. In order to request currency data, add the currencies codes together to form a currency pair. For example EURUSD can be requested by adding EUR and USD together. In order to get the inverse of the same pair, simply reverse the quote to USDEUR.
To access JSON object containing all available currency codes verus USD, Simply append your api_key
to the TraderMade exchange rates API apicurrencies endpoint.
https://marketdata.tradermade.com/api/v1/live_currencies_list?api_key=api_key
{
"available_currencies": {
"AED":"UAE Dirham",
"ARS":"Argentine Peso",
"AUD":"Australian Dollar",
"BHD":"Bahraini Dinar",
"BRL":"Brazilian Real",
"CAD":"Canadian Dollar",
"CHF":"Swiss Franc",
"CLP":"Chilean Peso",
"CNY":"Chinese Yuan",
"COP":"Colombian Peso",
"CZK":"Czech Koruna",
"DKK":"Danish Krone",
"EUR":"Euro",
"GBP":"British Pound Sterling",
"HKD":"Hong Kong Dollar",
"HRK":"Croatian Kuna",
"HUF":"Hungarian Forint",
"IDR":"Indonesian Rupiah",
"ILS":"Israeli New Sheqel",
"INR":"Indian Rupee",
"ISK":"Icelandic Krona",
"JPY":"Japanese Yen",
"KRW":"South Korean Won",
"KWD":"Kuwaiti Dinar",
"MAD":"Moroccan Dirham",
"MXN":"Mexican Peso",
"MYR":"Malaysian Ringgit",
"NGN":"Nigerean Naira",
"NOK":"Norwegian Krone",
"NZD":"New Zealand Dollar",
"OMR":"Omani Rial",
"PEN":"Peruvian Nuevo Sol",
"PHP":"Philippine Peso",
"PLN":"Polish Zloty",
"RON":"Romanian Leu",
"RUB":"Russian Ruble",
"SEK":"Swedish Krona",
"SGD":"Singapore Dollar",
"THB":"Thai Baht",
"TRY":"Turkish Lira",
"TWD":"Taiwanese Dollar",
"USD":"US Dollar",
"VND":"Vietnamese Dong",
"ZAR":"South African Rand"
},
"endpoint": "live_currencies"
}
Live Crypto List
We offer data for 4000+ cryptocurrency pairs. A list of Forex and Crypto codes for live endpoint can be accessed by visting our
live currencies list page. A list of the available cryptocurrencies for the /live endpoint, can be accessed through requesting the live_cypto_list endpoint. In order to request currency data, add the currencies codes together to form a currency pair. For example DOGEUSD can be requested by adding DOGE and USD together. In order to get the inverse of the same pair, simply reverse the quote to USDDOGE.
To access JSON object containing all available crypto codes verus USD, Simply append your api_key
to the TraderMade live crypto API endpoint.
https://marketdata.tradermade.com/api/v1/live_crypto_list?api_key=api_key
{
"available_currencies": {
"ADA": "Cardano",
"ATOM": "Atom",
"AVAX": "Avalanche",
"AXS": "Axis infinity",
"BCH": "Bitcoin Cash",
"BNB": "Binance Coin",
"BTC": "Bitcoin",
"BTG": "Bitcoin Gold",
"BUSD": "Binance USD",
"DAI": "DAI",
"DASH": "Dashcoin",
"DOGE": "DogeCoin",
"DOT": "Polkadot",
"EGLD": "Elrond Egold",
"ENJ": "ENJ",
"EOS": "EOS Platform",
"ETC": "Ethereum Classic",
"ETH": "Ethereum",
"FIL": "Filecoin",
"FLOW": "Flow",
"FTM": "Fantom USD",
"FTT": "FTX Token",
"GALA": "Gala",
"HBAR": "Hbar",
"HNT": "Helium",
"ICP": "Internet Computer Price ",
"LINK": "Chainlink",
"LRC": "Loopring",
"LTC": "Litecoin",
"LUNA": "Luna",
"MANA": "Decentraland",
"MATIC": "Matic",
"NEAR": "Near",
"NEO": "NEO",
"ROSE": "Rose",
"SAND": "Sandbox",
"SHIB": "Shiba inu",
"SOL": "Solana",
"THETA": "Theta",
"TRX": "Tron",
"UNI": "Uniswap",
"USDT": "Tether",
"UST": "Terra USD",
"VET": "Vechain",
"XLM": "Stellar",
"XMR": "Monero",
"XRP": "Ripple",
"XTZ": "Tezos"
},
"endpoint": "live_crypto"
}
Historical Currencies List
We support over 1600 currency pairs on our historical data endpoints A list of the available currencies for the historical, pandasDF, timeseries,, and the minute_historical endpoints, can be accessed through requesting the historical_currencies_list endpoint or visiting list of historical exchange rates page. Below example is an abbreviated version.
https://marketdata.tradermade.com/api/v1/historical_currencies_list?api_key=api_key
{
"available_currencies": [
"AEDEUR",
....
"EURPHP",
"EURPLN",
"EURRON",
"EURRUB",
"EURSEK",
"EURSGD",
"EURTHB",
"EURTRY",
"EURTWD",
"EURUSD",
"EURXAG",
"EURXAU",
"EURZAR",
"GBPAED",
"GBPAUD",
"GBPBRL",
"GBPCAD",
"GBPCHF",
"GBPCZK",
"GBPDKK",
"GBPEUR",
"GBPHKD",
"GBPHUF",
"GBPINR",
"GBPJPY",
"GBPKRW",
"GBPMXN",
"GBPMYR",
"GBPNOK",
"GBPNZD",
....
"ZARUSD"
],
"endpoint": "historical_currencies"
}
Endpoints
The TraderMade exchange rates API has nine endpoints serving different sets of data. Below has one example for each of the endpoints.
// live endpoint
https://marketdata.tradermade.com/api/v1/live?currency=EURGBP,GBPJPY&api_key=api_key
// historical
https://marketdata.tradermade.com/api/v1/historical?date=2019-10-10&api_key=api_key
// tick_historical
https://marketdata.tradermade.com//api/v1/tick_historical/GBPUSD/2024-09-11 08:30/2024-09-11 09:00?format=json&api_key=api_key
// tick_historical_sample
https://marketdata.tradermade.com//api/v1/tick_historical_sample/GBPUSD/2024-09-11 08:30/2024-09-11 09:00?format=json&api_key=api_key
// minute_historical
https://marketdata.tradermade.com/api/v1/minute_historical?currency=EURUSD&date_time=2019-10-09-13:24&api_key=api_key
// hour_historical
https://marketdata.tradermade.com/api/v1/hour_historical?currency=EURUSD&date_time=2019-10-10-13:00&api_key=api_key
// convert
https://marketdata.tradermade.com/api/v1/convert?api_key=api_key&from=EUR&to=GBP&amount=1000
// timeseries
https://marketdata.tradermade.com/api/v1/timeseries?start_date=2015-01-01&end_date=2015-05-01&api_key=api_key
// pandasDF
https://marketdata.tradermade.com/api/v1/pandasDF?currency=EURUSD&start_date=2015-01-01&end_date=2015-05-01&api_key=api_key
// market_open_status
https://marketdata.tradermade.com/api/v1/market_open_status?api_key=api_key
Error Codes
Below are the error codes and responses for all the api endpoints.
Request parameters:
Codes |
HTTP Status |
Message |
401 |
200 - OK |
api key is invalid | your plan doesnt allow access to this dataset |
204 |
200 - OK |
data for the date requested not available | currency pair currently not available |
400 |
400 - BAD REQUEST |
Input payload validation failed (often due to missing parameter or wrong input) example wrong currency code or date format or
enddate before start date |
403 |
403 - Forbidden |
no data for weekend | data outside max historical data we provide |
// 400 will return error which includes the details of the error
{
"errors": {
"date": "YYYY-MM-DD time data '2019-10-' does not match format '%Y-%m-%d'"
},
"message": "Input payload validation failed"
}
Live Rates
Request parameters:
Params |
Description |
currency |
EURUSD,GBPUSD,UK100 |
api_key |
Your API key |
https://marketdata.tradermade.com/api/v1/live?currency=EURUSD,GBPUSD,UK100&api_key=api_key
{
"endpoint": "live",
"quotes": [
{
"ask": 1.18183,
"base_currency": "EUR",
"bid": 1.18181,
"mid": 1.18182,
"quote_currency": "USD"
},
{
"ask": 1.31705,
"base_currency": "GBP",
"bid": 1.31704,
"mid": 1.31705,
"quote_currency": "USD"
},
{
"ask": 6310.5,
"bid": 6309.8,
"instrument": "UK100",
"mid": 6310.1499
}
],
"requested_time": "Fri, 13 Nov 2020 11:42:51 GMT",
"timestamp": 1605267771
}
Historical Rates
The historical endpoint provides daily exchange rate data for the available currency pairs. Our daily bars are 22/22 as is the norm in financial markets. The daily bar finishes at and starts from 22:00 GMT. Our API lets you query any trading day over the past 20+ years (for some exotic currency pairs history may be less). The trading week starts from 22:00 hours on a Sunday and if date is requested for Saturday or Sunday Friday date is returned.
Request parameters:
Params |
Description |
currency |
EURUSD,GBPUSD |
date |
2019-10-09 |
api_key |
Your API key |
https://marketdata.tradermade.com/api/v1/historical?currency=EURUSD,GBPUSD&date=2019-10-09&api_key=api_key
{
"date": "2019-10-09",
"endpoint": "historical",
"quotes": [
{
"base_currency": "EUR",
"close": 1.09702,
"high": 1.09905,
"low": 1.0952,
"open": 1.09571,
"quote_currency": "USD"
},
{
"base_currency": "GBP",
"close": 1.2206,
"high": 1.22925,
"low": 1.21977,
"open": 1.22188,
"quote_currency": "USD"
}
],
"request_time": "Thu, 31 Oct 2019 14:40:52 GMT"
}
Tick Historical Rates
The Tick historical endpoint provides tick FX rate data for 50+ currency pairs. You can visit full currencies list page for complete list of codes. Historical Tick provides one month of data with each chunk not exceeding 60 minutes. This is only available on Advanced plan and uses 5 API request each time and only can be requested one currency pair per request.
You can't access tick historical without advanced plan but you can request a sample tick (shown below) which will get you to tick data going back 4 working days not including today. A maximum chunk of tick data in one request is 30 minutes and will take 5 requests away. You can only request one currency pair per request.
https://marketdata.tradermade.com/api/v1/tick_historical_sample/GBPUSD/2024-09-11 08:30/2024-09-11 09:00?api_key=api_key&format=json
Request parameters:
Params |
Description |
URL |
/tick_historical/symbol/startdate/enddate |
symbol |
GBPUSD |
startdate |
YYYY-mm-dd HH:MM - (2024-09-11 08:30) |
enddate |
YYYY-mm-dd HH:MM - (2024-09-11 09:00) |
format |
json or csv - default is json |
api_key |
Your API key |
https://marketdata.tradermade.com/api/v1/tick_historical/GBPUSD/2024-09-11 08:30/2024-09-11 09:00?api_key=api_key&format=json
{
"end_date": "2020-10-13 09:00",
"endpoint": "tick_historical",
"instrument": "GBPUSD",
"quotes": [
{
"ask": 1.30363,
"bid": 1.30359,
"inst": "GBPUSD",
"time": 1602577800339
},
{
"ask": 1.30363,
"bid": 1.30361,
"inst": "GBPUSD",
"time": 1602577800539
},
{
"ask": 1.3036,
"bid": 1.30357,
"inst": "GBPUSD",
"time": 1602577800941
},
{
"ask": 1.30363,
"bid": 1.3036,
"inst": "GBPUSD",
"time": 1602577801739
}
...
],
"start_date": "2020-10-13 08:30"
}
Minute Historical Rates
The API lets you query historical data for any minute for the past 30-years. You can only request one currency pair and one minute of data in one single request.
Request parameters:
Params |
Description |
currency |
EURUSD |
date_time |
YYYY-mm-dd-HH:MM - (2019-10-10-13:24) |
api_key |
Your API key |
https://marketdata.tradermade.com/api/v1/minute_historical?currency=EURUSD&date_time=2019-10-09-13:24&api_key=api_key
{
"endpoint": "minute_historical",
"currency": "EURUSD",
"date_time": "2019-10-09-13:24",
"close": 1.09802,
"high": 1.09816,
"low": 1.09798,
"open": 1.09807,
"request_time": "Thu, 31 Oct 2019 15:45:43 GMT"
}
Hour Historical Rates
The API provides historical rates (ohlc) for the given hour over the past two-years
Request parameters:
Params |
Description |
currency |
EURUSD |
date_time |
2019-10-10-13:00 |
api_key |
Your API key |
https://marketdata.tradermade.com/api/v1/hour_historical?currency=EURUSD&api_key=api_key&date_time=2019-10-10-13:00
{
"currency": "EURUSD",
"date_time": "2019-10-10-13:00",
"endpoint": "hour_historical",
"close": 1.10193,
"high": 1.10282,
"low": 1.10158,
"open": 1.10234,
"request_time": "Thu, 31 Oct 2019 15:45:43 GMT"
}
Timeseries
Time series api provides historical currency rates (OHLC) for daily, hourly and granular endpoints. Daily timeseries data is available for upto 15-year (for some exotic currency pairs history may be less) but max request is one-year per request. Hourly data for up to 12-month (max one month data per request) and minute interval data for upto one month (max 2 days data per call). For example, if you are requesting 15 minute data on Friday you can only request start date from Thursday 00:00 GMT (in one call). Only one currency pair can be requested at a time.
History -
daily - fifteen years | hourly - 12 months | minute - 1 Month
Request parameters:
Params |
Description |
currency |
EURUSD |
start_date |
daily - 2019-10-01 (YYYY-MM-DD) | hourly / minute - (YYYY-MM-DD-HH:MM) |
end_date |
daily - 2019-10-10 (YYYY-MM-DD) | hourly / minute - (YYYY-MM-DD-HH:MM) |
interval |
daily (other choices are - hourly or minute) |
period |
Daily Interval equals 1 | Hourly interval, choices are - 1, 2, 4, 6, 8, 24 | Minute interval, choices are - 1, 5, 10, 15, 30 |
format |
records (other choices are - csv, index , columns, split) |
api_key |
Your API key |
https://marketdata.tradermade.com/api/v1/timeseries?currency=EURUSD&api_key=api_key&start_date=2019-10-01&end_date=2019-10-10&format=records
You can also use our timeseries endpoint to plot data in highcharts - just replace apikey with your api key. You can read the
chart tutorial here
https://marketdata.tradermade.com/api/v1/timeseries?currency=EURUSD&api_key=api_key&start_date=2024-09-11-00:00&end_date=2024-09-12-10:10&format=records&interval=hourly
https://marketdata.tradermade.com/api/v1/timeseries?currency=EURUSD&api_key=api_key&start_date=2024-09-11-00:00&end_date=2024-09-12-10:10&format=records&interval=minute&period=15
{
"base_currency": "EUR",
"end_date": "2019-10-10",
"endpoint": "timeseries",
"quote_currency": "USD",
"quotes": [
{
"close": 1.09331,
"date": "2019-10-01",
"high": 1.09437,
"low": 1.0879,
"open": 1.08991
},
{
"close": 1.09591,
"date": "2019-10-02",
"high": 1.09638,
"low": 1.09039,
"open": 1.09331
},
....
{
"close": 1.10055,
"date": "2019-10-10",
"high": 1.10341,
"low": 1.09702,
"open": 1.09711
}
],
"request_time": "Thu, 31 Oct 2019 15:34:09 GMT",
"start_date": "2019-10-01"
}
Pandas Data Frame
PandasDF api endpoint provides daily OHLC data for the currency requested in a pandas Data Frame that makes it really easy for python developers to use historical currency data. Request single currency when field parameter is "ohlc". Can request multiple currency when field is "close". Data is available for upto 15-year (for some exotic currency pairs history may be less) but max request is one-year per request.
Request parameters:
Params |
Description |
currency |
EURUSD |
start_date |
2019-10-01 |
end_date |
2019-10-10 |
format |
records (other choices are - index , columns, split) |
fields |
ohlc (other choice is - close) |
api_key |
Your API key |
https://marketdata.tradermade.com/api/v1/pandasDF?currency=EURUSD&api_key=api_key&start_date=2019-10-01&end_date=2019-10-10&format=records&fields=ohlc
[
{
"close": 1.09331,
"date": "2019-10-01",
"high": 1.09437,
"low": 1.0879,
"open": 1.08991
},
{
"close": 1.09591,
"date": "2019-10-02",
"high": 1.09638,
"low": 1.09039,
"open": 1.09331
},
....
{
"close": 1.10055,
"date": "2019-10-10",
"high": 1.10341,
"low": 1.09702,
"open": 1.09711
}
]
Convert
The API provides conversion from one currency to another in real-time.
Request parameters:
Params |
Description |
from |
EUR |
to |
GBP |
amount |
1000 |
api_key |
Your API key |
https://marketdata.tradermade.com/api/v1/convert?api_key=api_key&from=EUR&to=GBP&amount=1000
{
"base_currency": "EUR",
"quote": 0.861,
"quote_currency": "GBP",
"requested_time": "Thu, 31 Oct 2019 14:46:35 GMT",
"timestamp": 1572533196,
"total": 861
}
Market Open Status
The API provides status of market open and close. When market is open the next_close provides a datetime string and next_open is an empty string.
When market is close next_close is an empty string and next_open provides a datetime string.
Request parameters:
Params |
Description |
api_key |
Your API key |
https://marketdata.tradermade.com/api/v1/market_open_status?api_key=api_key
{
"AUS200": {
"index": 14,
"instrument": "AUS200",
"next_close": "2022-11-21 21:00",
"next_open": "",
"status": "open"
},
"Copper": {
"index": 9,
"instrument": "Copper",
"next_close": "2022-11-21 22:00",
"next_open": "",
"status": "open"
}....
"FX": {
"index": 19,
"instrument": "FX",
"next_close": "2022-11-21 22:00",
"next_open": "",
"status": "open"
}
}
PHP (CURL)
Below is an example for convert exchange rates data using PHP (CURL):
?php
$curl = curl_init();
curl_setopt_array( $curl, array(
CURLOPT_PORT => "443",
CURLOPT_URL => "https://marketdata.tradermade.com/api/v1/convert?from=EUR&to=USD&amount=1000&api_key=api_key",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?php
$curl = curl_init();
curl_setopt_array( $curl, array(
CURLOPT_PORT => "443",
CURLOPT_URL => "https://marketdata.tradermade.com/api/v1/convert?from=EUR&to=USD&amount=1000&api_key=api_key",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Python
Below is an example for live exchange rates data using Python:
See our tutorial on Fetch Forex API with Python and Pandas
import requests
url = "https://marketdata.tradermade.com/api/v1/live"
querystring = {"currency":"USDJPY","api_key":"api_key"}
response = requests.get(url, params=querystring)
print(response.json())
import requests
url = "https://marketdata.tradermade.com/api/v1/live"
querystring = {"currency":"USDJPY","api_key":"api_key"}
response = requests.get(url, params=querystring)
print(response.json())
R
Below is an example for live exchange rates data using R:
See our detailed tutorial to Learn how to get live and historical forex data using R language.
library(httr)
library(jsonlite)
req <- "https://marketdata.tradermade.com/api/v1/live?currency=EURUSD,GBPUSD&api_key=api_key"
data_raw <- GET(url = req)
data_text = content(data, "text", encoding = "UTF-8")
data_json = fromJSON(data_text, flatten=TRUE)
dataframe = as.data.frame(data_json)
dataframe
library (httr)
library (jsonlite)
req <- "https://marketdata.tradermade.com/api/v1/live?currency=EURUSD,GBPUSD&api_key=api_key"
data_raw <- GET(url = req)
data_text = content(data_raw, "text", encoding = "UTF-8")
data_json = fromJSON(data_text, flatten=TRUE)
dataframe = as.data.frame(data_json)
dataframe
Go
Below is an example for live exchange rates data using Golang:
For further explanation See our tutorials on Get live forex data and parse REST JSON API with GoLang
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
)
type data struct {
Endpoint string `json:'endpoint'`
Quotes []map[string]interface{} `json:'quotes'`
Requested_time string `json:'requested_time'`
Timestamp int32 `json:'timestamp'`
}
func main(){
currencies := "EURUSD,GBPUSD"
api_key := "api_key"
url := "https://marketdata.tradermade.com/api/v1/live?currency=" + currencies + "&api_key=" + api_key
resp, getErr := http.Get(url)
if getErr != nil {
log.Fatal(getErr)
}
body, readErr := ioutil.ReadAll(res.Body)
if readErr != nil {
log.Fatal(readErr)
}
fmt.Println(string(body))
data_obj := data{}
jsonErr := json.Unmarshal(body, &data_obj)
if jsonErr != nil {
log.Fatal(jsonErr)
}
fmt.Println("endpoint", data_obj.Endpoint, "requested time", data_obj.Requested_time, "timestamp", data_obj.Timestamp)
for key, value := range data_obj.Quotes {
fmt.Println(key)
fmt.Println("symbol", value["base_currency"]+value["quote_currency"], "bid", value["bid"], "ask", value["ask"],
"mid", value["mid"])
}
}
}
C#
Below is an example for live exchange rates data using C#:
For further explanation See our tutorials on Get live forex data and parse REST JSON API with C#
using System;
using System.Net.Http;
using Newtonsoft.Json;
namespace crest
{
class Program
{
static async System.Threading.Tasks.Task Main(string[] args)
{
HttpClient client = new HttpClient();
HttpResponseMessage response = await client.GetAsync("https://marketdata.tradermade.com/api/v1/live?currency=EURUSD,GBPUSD&api_key=api_key");
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<CurrencyDetails>(responseBody);
foreach (var item in result.quotes)
{
Console.WriteLine(" Result: " + item.base_currency + "/" + item.quote_currency + " " + item.mid);
}
}
public class CurrencyDetails
{
public string endpoint { get; set; }
public quotes[] quotes { get; set; }
public string requested_time { get; set; }
public long timestamp { get; set; }
}
public class quotes
{
public double ask { get; set; }
public double bid { get; set; }
public string base_currency { get; set; }
public double mid { get; set; }
public string quote_currency { get; set; }
}
}
}
JavaScript (axios)
Below is an example for historical exchange rates data using JavaScript, Axios and NodeJS:
For further explanation See our tutorials on Get live forex data and parse REST JSON API with JavaScript, Axios and NodeJS
const axios = require('axios');
axios.get('https://marketdata.tradermade.com/api/v1/live?currency=EURUSD,GBPUSD,UK100&api_key=api_key')
.then(response => {
console.log(response.data);
console.log(response.data.quotes[1]);
})
.catch(error => {
console.log(error);
});
const axios = require('axios');
axios.get('https://marketdata.tradermade.com/api/v1/live?currency=EURUSD,GBPUSD,UK100&api_key=api_key')
.then(response => {
console.log(response.data);
console.log(response.data.quotes[1]);
})
.catch(error => {
console.log(error);
});
JavaScript (fetch)
Below is an example for historical exchange rates data using jQuery:
var requestOptions = {
method : 'GET',
redirect : 'follow'
};
fetch( 'https://marketdata.tradermade.com/api/v1/historical?currency=EURUSD%2CGBPUSD&date=2019-10-09&api_key=api_key', requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log( 'error', error));
var requestOptions = {
method : 'GET',
redirect : 'follow'
};
fetch( 'https://marketdata.tradermade.com/api/v1/historical?currency=EURUSD%2CGBPUSD&date=2019-10-09&api_key=api_key', requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log( 'error', error));
JavaScript (jQuery)
Below is an example for historical exchange rates data using jQuery:
var settings = {
"url": "https://marketdata.tradermade.com/api/v1/historical?currency=EURUSD%2CGBPUSD&date=2019-10-09&api_key=api_key",
"method": "GET",
"timeout": 0,
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var settings = {
"url": "https://marketdata.tradermade.com/api/v1/historical?currency=EURUSD%2CGBPUSD&date=2019-10-09&api_key=api_key",
"method": "GET",
"timeout": 0,
};
$.ajax(settings).done(function (response) {
console.log(response);
});