lang | title | description |
---|---|---|
en-US |
Quick Start Guide 🚀 |
Currency API |
Currency API is fast and friendly crypto, commodity, and FX Currency Conversion JSON API, covering over 1200+ pairs.
We've made it easy to be up and running. All you need to do is to visit "My Account" and locate your token. If you don't have one yet, please subscribe and get one immediately.
Get ready to connect to Currency API using few coding lines of your favorite programming language.
Definition | Description |
---|---|
API URL | The URL which all API request endpoints and URLs are based on. |
Token | The access key assigned to your account and used to authenticate with the API. |
Symbol | The three-letter currency code or currency pair (e.g., EUR, EURUSD). |
Base Currency | The currency to which exchange rates are relative to. (If 1 USD = X EUR, USD is the base currency) |
Target Currency | The currency an amount is converted to. (If 1 USD = X EUR, EUR is the target currency) |
Timestamp format | All timestamps are unix/epoch timestamps (seconds that have passed since since January 1, 1970 UTC). |
The Currency API comes with a single endpoint that enables you to query one or many currency codes or pairs, with readable parameters. Depending on your subscription plan, the endpoint will return real-time exchange rate data.
https://api.currencyapi.io/
Your API token is a unique access key passed into the API URL's token parameter to authenticate with the Currency API. The following is an example of how to append the access token for authentication:
https://api.currencyapi.io/markets
?token=ACCESS_TOKEN
To get the complete list of a specific market (e.g., Forex, Crypto, etc.) available symbols/pairs, use the following endpoint. Replace the MARKET_NAME
with the targeted market (crypto or forex)
https://api.currencyapi.io/markets
?token=ACCESS_TOKEN
&market=MARKET_NAME
/markets
endpoint provides you the ability to query a base currency (e.g., EUR) or currency pair (e.g.,EURUSD).
GET https://api.currencyapi.io/markets
?token=ACCESS_TOKEN
&search=SYMBOL
Response
[
{
"t":"2021-04-15T03:53:00.593Z",
"tms":"1618458780086",
"s":"EURUSD",
"b":1.19864,
"bd":0,
"a":1.19867,
"ad":1,
"p":5
}
]
GET https://api.currencyapi.io/markets
?token=ACCESS_TOKEN
&symbol=SYMBOL
Response
{
"t":"2021-04-15T03:53:00.593Z",
"tms":"1618458780086",
"s":"EURUSD",
"b":1.19864,
"bd":0,
"a":1.19867,
"ad":1,
"p":5
}
Key | Description |
---|---|
t | The last update date/time of query result. |
tms | The last update timestamp of query result. |
s | The currency pair. |
b | The bid price. It is also referring to the highest price a buyer will pay for a currency. |
bd | The bid price direction. It is also referring to the color code of the displayed bid price (e.g., red/green). |
a | The ask price. It is also referring to the lowest price a seller will accept for a currency. |
ad | The ask price direction. It is also referring to the color code of the displayed ask price (e.g., red/green). |
p | The Currency precision |
You can get the historical data of any of the available symbols by adding the historical
parameter.
Response
[
[
1620604800,
58336.16,
59603,
57399.33,
57960
],
...
]
GET https://api.currencyapi.io/markets
?token=ACCESS_TOKEN
&symbol=SYMBOL
&historical=true
&offset=OFFSET // Optional (candles offset)
&scale=SCALE // Optional (e.g., 1, 60, 1D, 1W, 1M), default to 1D
index | Description |
---|---|
0 | Timestamp. |
1 | Open. |
2 | High. |
3 | Low. |
4 | Close. |
Currency API supports your favorite programming languages. Here are few examples of how to connect and start getting real-time quotes:
var requestOptions = {
method: 'GET',
redirect: 'follow'
};
fetch(
"https://api.currencyapi.io/markets?token=ACCESS_TOKEN&symbol=SYMBOL",
requestOptions
)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
var settings = {
"url": "https://api.currencyapi.io/markets?token=ACCESS_TOKEN&symbol=SYMBOL",
"method": "GET",
"timeout": 0,
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.currencyapi.io/markets?token=ACCESS_TOKEN&symbol=SYMBOL");
xhr.send();
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open(
"GET",
"https://api.currencyapi.io/markets?token=ACCESS_TOKEN&symbol=SYMBOL"
);
xhr.send();
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl(
'https://api.currencyapi.io/markets?token=ACCESS_TOKEN&symbol=SYMBOL'
);
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setConfig(array(
'follow_redirects' => TRUE
));
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl(
'https://api.currencyapi.io/markets?token=ACCESS_TOKEN&symbol=SYMBOL'
);
$request->setRequestMethod('GET');
$request->setOptions(array());
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
import http.client
conn = http.client.HTTPSConnection("api.currencyapi.io")
conn.request(
"GET",
"/markets?token=ACCESS_TOKEN&symbol=SYMBOL",
)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "https://api.currencyapi.io/markets?token=ACCESS_TOKEN&symbol=SYMBOL"
payload={}
headers = {}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
$response = Invoke-RestMethod 'https://api.currencyapi.io/markets?token=ACCESS_TOKEN&symbol=SYMBOL' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
curl --location --request GET 'https://api.currencyapi.io/markets?token=ACCESS_TOKEN&symbol=SYMBOL'
var client = new RestClient("https://api.currencyapi.io/markets?token=ACCESS_TOKEN&symbol=SYMBOL");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.currencyapi.io/markets?token=ACCESS_TOKEN&symbol=SYMBOL"
method := "GET"
client := &http.Client {
}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
require "uri"
require "net/http"
url = URI("https://api.currencyapi.io/markets?token=ACCESS_TOKEN&symbol=SYMBOL")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Get.new(url)
response = https.request(request)
puts response.read_body
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
var semaphore = DispatchSemaphore (value: 0)
var request = URLRequest(url: URL(
string: "https://api.currencyapi.io/markets?token=ACCESS_TOKEN&symbol=SYMBOL")!,
timeoutInterval: Double.infinity
)
request.httpMethod = "GET"
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
semaphore.signal()
return
}
print(String(data: data, encoding: .utf8)!)
semaphore.signal()
}
task.resume()
semaphore.wait()
var axios = require('axios');
var config = {
method: 'get',
url: 'https://api.currencyapi.io/markets?token=ACCESS_TOKEN&symbol=SYMBOL',
headers: { }
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://api.currencyapi.io/markets?token=ACCESS_TOKEN&symbol=SYMBOL',
'headers': {
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.currencyapi.io/markets?token=ACCESS_TOKEN&symbol=SYMBOL")
.method("GET", null)
.build();
Response response = client.newCall(request).execute();
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.get("https://api.currencyapi.io/markets?token=ACCESS_TOKEN&symbol=SYMBOL")
.asString();