Historical exchange rate data is popularly used in currency trading applications. Investors frequently use historical currency data in foreign exchange trading applications. It is a service that shapes the investments of investors.
Historical exchange rate data is provided by APIs that provide currency conversion services. Today there are many APIs that provide this service. The most popular historical exchange rate API preferred by giant companies such as Kranken and Samsung is Fixer API. Fixer API provides both current and historical data to its users in just milliseconds.
Fixer API provides current and historical currency data for 170 currencies. It obtains the data provided by various official financial institutions and banks, especially the European Central Bank.
Fixer API is developed by developers with a developer-friendly approach. Quickly integrated, the JSON API is flexible and can be integrated into applications in a few steps. In addition, it provides a lot of information to both developers and business owners with very strong documentation.
Now we will talk about how to integrate Fixer API into 5 different programming languages.
Fixer API with 5 different programming languages
We will integrate the historical exchange rate data service provided by Fixer API into 5 different programming languages.
Before proceeding with the integration, we select one of the most exclusive and affordable packages of Fixer API and become a member. Then we obtain the API key required to use the Fixer API.
After obtaining the API key, we can look at the integration of Fixer API with different programming languages.
Javascript
var requestOptions = { method: ‘GET’, redirect: ‘follow’ }; fetch(“http://data.fixer.io/api/2015-09-08?access_key=c05*****ff&symbols=USD,TRY,CAD”, requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log(‘error’, error)); |
Go
package main import ( “fmt” “net/http” “io/ioutil” ) func main() { url := “http://data.fixer.io/api/2015-09-08?access_key=c0*****ff&symbols=USD,TRY,CAD” 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)) } |
Nodejs
var axios = require(‘axios’); var config = { method: ‘get’, url: ‘http://data.fixer.io/api/2015-09-08?access_key=c05*****ff&symbols=USD,TRY,CAD’, headers: { } }; axios(config) .then(function (response) { console.log(JSON.stringify(response.data)); }) .catch(function (error) { console.log(error); }); |
Python
conn = http.client.HTTPSConnection(“data.fixer.io”) payload = ” headers = {} conn.request(“GET”, “/api/2015-09-08?access_key=c0*****ff&symbols=USD,TRY,CAD”, payload, headers) res = conn.getresponse() data = res.read() print(data.decode(“utf-8”)) |
PHP
<?php require_once ‘HTTP/Request2.php’; $request = new HTTP_Request2(); $request->setUrl(‘http://data.fixer.io/api/2015-09-08?access_key=c05*****ff&symbols=USD,TRY,CAD’); $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(); } |
We have implemented the integration of Fixer API with applications very simply and quickly. If the ‘base’ field is not set in the request to the Fixer API, EUR is selected by default. We did not set the ‘base’ field either, and we expect the values of USD, TRY and CAD currencies to correspond to the EUR currency on the date we specified.
When these applications are run, the following output will be printed on the console screen of the applications.
{ “success”: true, “timestamp”: 1441670399, “historical”: true, “base”: “EUR”, “date”: “2015-09-08”, “rates”: { “USD”: 1.120599, “TRY”: 3.377687, “CAD”: 1.481852 } } |
Conclusion
The popularity of historical exchange rate data is increasing. It is an element that determines investment plans for investors. By integrating Fixer API into your applications in just a few steps, you can convince medium and large-scale investors to use your applications.
Recent Comments