There are so many currency pairs in the market today, therefore; one needs to have the best streaming Currency API to get accurate and the latest currency market data. These Currency stream APIs are used to express or display data on currency pairs. Therefore, the API could be termed as a pipeline of flowing data and updates on the currency pairs. The information is produced by modifying other streams or reading the messages from a source. In our previous posts, we have talked exhaustively about currency converters, how to use them, and even went deeper and created a few source codes. In line with that, today we will be discussing 5 Best Currency API Streaming Pair Sources. Do not leave yet because the best is coming. However, before then, why are the Currency APIs that stream pair sources so important?
The Importance of Currency Streaming APIs
Most financial institutions are turning to Currency APIs that stream pair sources to have fast and real-time trading data. There is always a prompt and quick data delivery. To get data from one source as opposed to the many sources which were time-consuming and mostly unreliable? Without much ado, let us jump to our topic.
5 Best Currency API Streaming Pair Sources
As the world continues to experience the revolution in every sector, the financial sector has not been left behind. In that line, currency APIs has been created in tons to match the ever-emerging need for streaming live data. The result has been amazing, nowadays; getting financial data across the globe just takes a twinkling of an eye. In this post, we will be going through the 5 best currency API streaming pair sources namely,
Currencyapi.io
Currencylayer
Nomics API
Fixer API
Coin Mill
Let us walk this knowledge journey together.
Currencyapi.io
Currencyapi.io is one of the best currency APIs that stream currency pairs seamlessly. It is a fast, reliable, and friendly. It is a commodity, crypto as well as FX currency API. It is built for developers and other financial users. Easy to use, precise documentation, reliable, and covers all currency pairs. Not that alone, it also covers silver, gold, and foreign exchange.
What do you stand to benefit?
You will access 300 plus crypto assets, and 1800Plus FX.
Uncompromised data security equated to that of the bank.
Get reliable and trusted data.
Get technical support like no other to integrate to the currencyapi.io.
Get uncompromised real-time rates for all pairs.
Currencyapi.io offers a single data source for faster consumption and reliability.
You will also be able to get a free trial valid for seven days otherwise known as the starter plan. There is also a premium plan that has added benefits.
Now let us have a look at some codes,
Getting latest currency updates,
{
"base": "USD",
"last_updated_unix": "1593614038",
"last_updated_utc": "Wed, 01 Jul 2020 14:33:58 +0000",
"exchange_rate": {
"EUR": 0.889758,
"CAD": 1.35676,
"AUD": 1.44753,
"GBP": 0.807175,
"CHF": 0.946451,
"CNY": 7.06409,
...
...
}
}
Target currencies examples
{
"base": "USD",
"last_updated_unix": "1593614038",
"last_updated_utc": "Wed, 01 Jul 2020 14:33:58 +0000",
"exchange_rate": {
"SGD": 1.39392,
"MYR": 4.28634,
"IDR": 14312.03
}
Getting data using Currencyapi.io
The first step is to get the API’s url,
https://api.currencyapi.io/
After that, you will have to get the access Key or token. It is the gateway to your access to the platform as below,
https://api.currencyapi.io/markets
?token=ACCESS_TOKEN
To get all pairs in a given market segment, follow the code below,
https://api.currencyapi.io/markets
?token=ACCESS_TOKEN
&market=MARKET_NAME
For those who have subscribed to the premium plan, they can access historical data as illustrated below,
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
That is not all you can also use Python to get live exchange rates via currecyapi.io for both import requests and import client as per the codes below.
import requests
tuper = "https://api.currencyapi.io/markets?token=ACCESS_TOKEN&symbol=EURUSD"
payload={}
headers = {}
res = requests.request("GET", tuper, headers=headers, data=payload)
print(res.text)
import http.client
duer = http.client.HTTPSConnection("api.currencyapi.io")
duer.request(
"GET",
"/markets?token=ACCESS_TOKEN&symbol=EURUSD",
)
response = duer.getresponse()
data = response.read()
print(data.decode("utf-8"))
Finally, below is the process for creating a converter using python via currencyapi.
def __init__(self, converter):
tk.Tk.__init__(self)
self.title = 'Currency Converter'
self.currency_converter = converte
self.geometry("500x200")
#Label
self.intro_label = Label(self, text = 'Welcome to Real Time Currency Convertor', fg = 'blue', relief = tk.RAISED, borderwidth = 3)
self.intro_label.config(font = ('Courier',15,'bold'))
self.date_label = Label(self, text = f"1 Indian Rupee equals = {self.currency_converter.convert('INR','USD',1)} USD \n Date : {self.currency_converter.data['date']}", relief = tk.GROOVE, borderwidth = 5)
self.intro_label.place(x = 10 , y = 5)
self.date_label.place(x = 170, y= 50)
# Entry box
valid = (self.register(self.restrictNumberOnly), '%d', '%P')
# restricNumberOnly function will restrict thes user to enter invavalid number in Amount field. We will define it later in code
self.amount_field = Entry(self,bd = 3, relief = tk.RIDGE, justify = tk.CENTER,validate='key', validatecommand=valid)
self.converted_amount_field_label = Label(self, text = '', fg = 'black', bg = 'white', relief = tk.RIDGE, justify = tk.CENTER, width = 17, borderwidth = 3)
# dropdown
self.from_currency_variable = StringVar(self)
self.from_currency_variable.set("INR") # default value
self.to_currency_variable = StringVar(self)
self.to_currency_variable.set("USD") # default value
font = ("Courier", 12, "bold")
self.option_add('*TCombobox*Listbox.font', font)
self.from_currency_dropdown = ttk.Combobox(self, textvariable=self.from_currency_variable,values=list(self.currency_converter.currencies.keys()), font = font, state = 'readonly', width = 12, justify = tk.CENTER)
self.to_currency_dropdown = ttk.Combobox(self, textvariable=self.to_currency_variable,values=list(self.currency_converter.currencies.keys()), font = font, state = 'readonly', width = 12, justify = tk.CENTER)
# placing
self.from_currency_dropdown.place(x = 30, y= 120)
self.amount_field.place(x = 36, y = 150)
self.to_currency_dropdown.place(x = 340, y= 120)
#self.converted_amount_field.place(x = 346, y = 150)
self.converted_amount_field_label.place(x = 346, y = 150)
# Convert button
self.convert_button = Button(self, text = "Convert", fg = "black", command = self.perform)
self.convert_button.config(font=('Courier', 10, 'bold'))
self.convert_button.place(x = 225, y = 135)
def perform(self,):
amount = float(self.amount_field.get())
from_curr = self.from_currency_variable.get()
to_curr = self.to_currency_variable.get()
converted_amount= self.currency_converter.convert(from_curr,to_curr,amount)
converted_amount = round(converted_amount, 2)
self.converted_amount_field_label.config(text = str(converted_amount))
def perform(self,):
amount = float(self.amount_field.get())
from_curr = self.from_currency_variable.get()
to_curr = self.to_currency_variable.get()
converted_amount= self.currency_converter.convert(from_curr,to_curr,amount)
converted_amount = round(converted_amount, 2)
self.converted_amount_field_label.config(text = str(converted_amount))
if __name__ == '__main__':
url = 'https://api.exchangerate-api.com/v4/latest/USD'
converter = RealTimeCurrencyConverter(url)
App(converter)
mainloop()
Currencylayer
An excellent Currency API that is JSON formatted and streams currency conversions and reliable exchange rates. It consists of 5 customizable terminals to take care of different tasks. They include Historical, live, convert, change, and timeframe endpoints.
The historical endpoint is responsible for historical data for exchange rates.
The live endpoint is responsible for instant or real-time forex rates.
Change endpoint takes care of currency change variables.
The timeframe terminal entails retrieving exchange rates for a certain duration.
Convert Terminal is used to convert various currencies.
We have created some code examples.
Currency listing terminal code,
// Response:
{
"success":true,
"terms":"https:\/\/currencylayer.com\/terms",
"privacy":"https:\/\/currencylayer.com\/privacy",
"currencies":{
"AED":"United Arab Emirates Dirham",
"AFN":"Afghan Afghani",
"ALL":"Albanian Lek",
"AMD":"Armenian Dram",
"ANG":"Netherlands Antillean Guilder",
"AOA":"Angolan Kwanza",
"ARS":"Argentine Peso",
"AUD":"Australian Dollar",
"BTC":"Bitcoin", // Yay bitcoin!
// ...
"USD":"United States Dollar",
"UYU":"Uruguayan Peso",
"UZS":"Uzbekistan Som",
"VEF":"Venezuelan Bol\u00edvar Fuerte",
"VND":"Vietnamese Dong"
}
}
An example of historical data code,
// 2016
{
"success":true,
"terms":"https:\/\/currencylayer.com\/terms",
"privacy":"https:\/\/currencylayer.com\/privacy",
"historical":true,
"date":"2016-05-08",
"timestamp":1462751999,
"source":"USD",
"quotes":{
"USDBTC":0.002177
}
}
// 2015
{
"success":true,
"terms":"https:\/\/currencylayer.com\/terms",
"privacy":"https:\/\/currencylayer.com\/privacy",
"historical":true,
"date":"2015-05-08",
"timestamp":1431129599,
"source":"USD",
"quotes":{
"USDBTC":0.004093
}
}
Example Real-time conversion rates,
# Retrieve the value of USD compared to EUR (the Euro)
# If you don't provide a "currencies" key, all currencies will be returned
curl http://apilayer.net/api/live?format=1¤cies=EUR&access_key=MY_API_KEY
{
"success":true,
"terms":"https:\/\/currencylayer.com\/terms",
"privacy":"https:\/\/currencylayer.com\/privacy",
"timestamp":1494266647,
"source":"USD",
"quotes":{
"USDEUR":0.914798
}
You can also pull bulk currency rates as below,
# Retrieve the value of USD compared to EUR (the Euro), GBP (Pound), BTC (Bitcoin)
curl http://apilayer.net/api/live?format=1¤cies=GBP,EUR,BTC&access_key=MY_API_KE
{
"success":true,
"terms":"https:\/\/currencylayer.com\/terms",
"privacy":"https:\/\/currencylayer.com\/privacy",
"timestamp":1494266647,
"source":"USD",
"quotes":{
"USDGBP":0.77271, // 1 USD is 0.77271 Pounds (GBP)
"USDEUR":0.914798,
"USDBTC":0.000628
}
}
The API supports precious metals and 160 currencies globally. The data from diverse sources including banks is verified and classified then dispersed to the consumers. The platform provides periodic data update within a span of one minute. The APP is simple and easy to use. To supplement their efforts, they provide comprehensive and accurate documentation for easy integration.
Nomics API
Nomics API provides data for both currencies and cryptocurrencies. They focus on cryptocurrency market cap, OHLC/Candle information for currency exchanges. The platform also offers historical data for crypto Market Cap. Any developer can use it. Below is a practical usage of the API.
import urllib.request
url = "https://api.nomics.com/v1/currencies/ticker?key=demo-26240835858194712a4f8cc0dc635c7a&ids=BTC,ETH,XRP&interval=1d,30d&convert=EUR"
print(urllib.request.urlopen(url).read())
[
{
"currency": "BTC",
"id": "BTC",
"price": "8451.36516421",
"price_date": "2019-06-14T00:00:00Z",
"price_timestamp": "2019-06-14T12:35:00Z",
"symbol": "BTC",
"circulating_supply": "17758462",
"max_supply": "21000000",
"name": "Bitcoin",
"logo_url": "https://s3.us-east-2.amazonaws.com/nomics-api/static/images/currencies/btc.svg",
"market_cap": "150083247116.70",
"transparent_market_cap": "150003247116.70",
"rank": "1",
"high": "19404.81116899",
"high_timestamp": "2017-12-16",
"1d": {
"price_change": "269.75208019",
"price_change_pct": "0.03297053",
"volume": "1110989572.04",
"volume_change": "-24130098.49",
"volume_change_pct": "-0.02",
"market_cap_change": "4805518049.63",
"market_cap_change_pct": "0.03",
"transparent_market_cap_change": "4800518049.00",
"transparent_market_cap_change_pct": "0.0430"
{
"grade": "B",
"volume": "15856762.85",
"volume_change": "-6854329.88",
"volume_change_pct": "-0.30"
}
]
}
}
]
Fixer API
The platform provides a very simple process of delivering Real-time conversions, and Forex rates to visitors to their Web. It comprises various terminals that are responsible for diverse tasks. The tasks include real-time forex data, Listing of all assets therein, historical currency data, extracting fluctuation data every day, and conversion of different currencies. The platform is easy to use with very exhaustive and comprehensive documentation. It has easy-to-follow code samples and is easy to integrate. It uses JSON data making it a straightforward platform that is simple to use.
Below is a fixer API code showing query or request for currency pair’s exchange rates.
>>> from fixerio import Fixerio
>>> fxrio = Fixerio()
>>> fxrio.latest()
After running the code we get the below results.
'''
{u'base': u'EUR',
u'date': u'2016-07-08',
u'rates': {u'AUD': 1.59141,
u'BGN': 1.95634,
u'BRL': 6.24962,
u'CAD': 1.48623,
[...]
}}
'''
By default, the exchange rate uses EUR as the base currency. If you wanted to request a single or several currency pairs add a symbol in the following sequence,‘currency1’, ‘currency2… (>>> fxrio = Fixerio(symbols=[‘USD’, ‘GBP’]) otherwise known as the quote for the currencies as illustrated above where USD is the currency1 and GBP Currency2.
>>> from fixerio import Fixerio
>>> fxrio = Fixerio(symbols=['USD', 'GBP'])
>>> fxrio.latest()
Leading to the below outcome,
'''
{u'base': u'EUR',
u'date': u'2016-07-08',
u'rates': {u'GBP': 0.85962, u'USD': 1.18454}}
'''
Coinmill Currency API
An easy-to-use and simple API that can be used on the Web APP. It uses JavaScript to display converted currency prices, Currency feeds on websites and blogs. It also enables the user to insert Real-time rates and currency conversions. The forms enable the users their preferred currency of conversion with instant results. It supports 80+ currencies and up-to-date data regarding forex rates.