### Fetch Latest Rates using C (libcurl) Source: https://currencyfreaks.com/documentation.html This C example uses the libcurl library to perform a GET request for currency rates. Ensure libcurl is installed and linked. ```c CURL *curl; CURLcode res; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET"); curl_easy_setopt(curl, CURLOPT_URL, "https://api.currencyfreaks.com/v2.0/rates/latest?base=gbp&symbols=pkr,usd,cad,eur&apikey=YOUR_APIKEY"); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https"); struct curl_slist *headers = NULL; curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); res = curl_easy_perform(curl); } curl_easy_cleanup(curl); ``` -------------------------------- ### Fetch Historical Rates using C Source: https://currencyfreaks.com/documentation.html This C example uses the libcurl library to make a GET request for historical currency rates. Ensure libcurl is installed and linked. ```c CURL *curl; CURLcode res; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET"); curl_easy_setopt(curl, CURLOPT_URL, "https://api.currencyfreaks.com/v2.0/rates/historical?date=2022-03-20&base=gbp&symbols=usd,eur,pkr,cad&apikey=YOUR_APIKEY"); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https"); struct curl_slist *headers = NULL; curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); res = curl_easy_perform(curl); } curl_easy_cleanup(curl); ``` -------------------------------- ### Fetch Historical Rates using Python Source: https://currencyfreaks.com/documentation.html This Python example uses the http.client library to make a GET request for historical currency rates. No external libraries are required. ```python import http.client conn = http.client.HTTPSConnection("api.currencyfreaks.com") payload = '' headers = {} conn.request("GET", "/v2.0/rates/historical?date=2022-03-20&base=gbp&symbols=usd,eur,pkr,cad&apikey=YOUR_APIKEY", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` -------------------------------- ### Call Currency Conversion Endpoint with C Source: https://currencyfreaks.com/documentation.html This C example uses libcurl to perform a GET request to the currency conversion API. It sets the URL and follows redirects. ```c CURL *curl; CURLcode res; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET"); curl_easy_setopt(curl, CURLOPT_URL, "https://api.currencyfreaks.com/v2.0/convert/latest?from=usd&to=pkr&amount=500&apikey=YOUR_APIKEY"); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https"); struct curl_slist *headers = NULL; curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); res = curl_easy_perform(curl); } curl_easy_cleanup(curl); ``` -------------------------------- ### Fetch Latest Rates using Node.js (Unirest) Source: https://currencyfreaks.com/documentation.html This Node.js example uses the Unirest library to fetch currency rates. Ensure you have Unirest installed (`npm install unirest request`). ```javascript var unirest = require('unirest'); var request = require('request'); var options = { 'method': 'GET', 'url': 'https://api.currencyfreaks.com/v2.0/rates/latest?base=gbp&symbols=pkr,usd,cad,eur&apikey=YOUR_APIKEY', 'headers': { } }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); }); ``` -------------------------------- ### Call Currency Conversion Endpoint with Go Source: https://currencyfreaks.com/documentation.html This Go example demonstrates making an HTTP GET request to the currency conversion API using the standard net/http package. It reads and prints the response body. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://api.currencyfreaks.com/v2.0/convert/latest?from=usd&to=pkr&amount=500&apikey=YOUR_APIKEY" 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)) } ``` -------------------------------- ### Fetch Historical Rates using Node.js Source: https://currencyfreaks.com/documentation.html This Node.js example uses the 'request' library to fetch historical currency rates. Ensure you have the 'request' library installed. ```javascript var request = require('request'); var options = { 'method': 'GET', 'url': 'https://api.currencyfreaks.com/v2.0/rates/historical?date=2022-03-20&base=gbp&symbols=usd,eur,pkr,cad&apikey=YOUR_APIKEY', 'headers': { } }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); }); ``` -------------------------------- ### Call Currency Conversion Endpoint with Python Source: https://currencyfreaks.com/documentation.html This Python example uses the http.client library to make a GET request to the currency conversion API. It prints the decoded response. ```python import http.client conn = http.client.HTTPSConnection("api.currencyfreaks.com") payload = '' headers = {} conn.request("GET", "/v2.0/convert/latest?from=usd&to=pkr&amount=500&apikey=YOUR_APIKEY", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` -------------------------------- ### Fetch Latest Rates using C# (RestClient) Source: https://currencyfreaks.com/documentation.html This C# example uses the RestSharp library to make a GET request for currency rates. Ensure RestSharp is added to your project. ```csharp var client = new RestClient("https://api.currencyfreaks.com/v2.0/rates/latest?base=gbp&symbols=pkr,usd,cad,eur&apikey=YOUR_APIKEY"); client.Timeout = -1; var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); ``` -------------------------------- ### Call Currency Conversion Endpoint with Node.js Source: https://currencyfreaks.com/documentation.html This Node.js example uses the 'request' library to fetch currency conversion data. Ensure you have the 'request' library installed. ```javascript var request = require('request'); var options = { 'method': 'GET', 'url': 'https://api.currencyfreaks.com/v2.0/convert/latest?from=usd&to=pkr&amount=500&apikey=YOUR_APIKEY', 'headers': { } }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); }); ``` -------------------------------- ### Fetch Time Series Rates using Node.js Source: https://currencyfreaks.com/documentation.html This Node.js example uses the 'request' library to fetch time series currency exchange rates. Ensure you have the 'request' library installed. ```javascript var request = require('request'); var options = { 'method': 'GET', 'url': 'https://api.currencyfreaks.com/v2.0/timeseries?startDate=2022-06-01&endDate=2022-06-07&base=eur&symbols=pkr,usd,gbp,cad&apikey=YOUR_APIKEY', 'headers': { } }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); }); ``` -------------------------------- ### Node.js Request for Historical Conversion Source: https://currencyfreaks.com/documentation.html Example using Node.js 'request' module to fetch historical currency conversion rates. Ensure the 'request' module is installed. ```javascript var request = require('request'); var options = { 'method': 'GET', 'url': 'https://api.currencyfreaks.com/v2.0/convert/historical?from=usd&to=pkr&amount=500&date=2022-01-10&apikey=YOUR_APIKEY', 'headers': { } }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); }); ``` -------------------------------- ### Fetch Historical Rates using Ruby Source: https://currencyfreaks.com/documentation.html This Ruby example uses the Net::HTTP library to fetch historical currency rates. It demonstrates making a GET request over HTTPS. ```ruby require "uri" require "net/http" url = URI("https://api.currencyfreaks.com/v2.0/rates/historical?date=2022-03-20&base=gbp&symbols=usd,eur,pkr,cad&apikey=YOUR_APIKEY") 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 ``` -------------------------------- ### Fetch Time Series Rates using Java (OkHttpClient) Source: https://currencyfreaks.com/documentation.html This Java example utilizes OkHttpClient to make a GET request for time series currency exchange rates. Include the OkHttpClient library in your project dependencies. ```java OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.currencyfreaks.com/v2.0/timeseries?startDate=2022-06-01&endDate=2022-06-07&base=eur&symbols=pkr,usd,gbp,cad&apikey=YOUR_APIKEY") .get() .build(); Response response = client.newCall(request).execute(); ``` -------------------------------- ### Call Currency Conversion Endpoint with Ruby Source: https://currencyfreaks.com/documentation.html This Ruby example uses Net::HTTP to make a GET request to the currency conversion API. It handles SSL and prints the response body. ```ruby require "uri" require "net/http" url = URI("https://api.currencyfreaks.com/v2.0/convert/latest?from=usd&to=pkr&amount=500&apikey=YOUR_APIKEY") 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 ``` -------------------------------- ### Fetch Historical Rates using C# Source: https://currencyfreaks.com/documentation.html This C# example uses the RestSharp library to make a GET request for historical currency rates. Ensure RestSharp is added to your project. ```csharp var client = new RestClient("https://api.currencyfreaks.com/v2.0/rates/historical?date=2022-03-20&base=gbp&symbols=usd,eur,pkr,cad&apikey=YOUR_APIKEY"); client.Timeout = -1; var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); ``` -------------------------------- ### Fetch Latest Rates using Java (OkHttpClient) Source: https://currencyfreaks.com/documentation.html This Java example demonstrates fetching currency rates using OkHttpClient. You need to include the OkHttpClient library in your project. ```java OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.currencyfreaks.com/v2.0/rates/latest?base=gbp&symbols=pkr,usd,cad,eur&apikey=YOUR_APIKEY") .get() .build(); Response response = client.newCall(request).execute(); ``` -------------------------------- ### Fetch Historical Rates using PHP Source: https://currencyfreaks.com/documentation.html This PHP example uses cURL to retrieve historical currency exchange rates. Ensure cURL is enabled in your PHP installation. ```php 'https://api.currencyfreaks.com/v2.0/rates/historical?date=2022-03-20&base=gbp&symbols=usd,eur,pkr,cad&apikey=YOUR_APIKEY', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', )); $response = curl_exec($curl); curl_close($curl); echo $response; ?> ``` -------------------------------- ### Fetch Time Series Rates using Ruby Source: https://currencyfreaks.com/documentation.html This Ruby example uses Net::HTTP to perform a GET request for time series currency exchange rates. It handles SSL and prints the response body. ```ruby require "uri" require "net/http" url = URI("https://api.currencyfreaks.com/v2.0/timeseries?startDate=2022-06-01&endDate=2022-06-07&base=eur&symbols=pkr,usd,gbp,cad&apikey=YOUR_APIKEY") 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 ``` -------------------------------- ### Call Currency Conversion Endpoint with Swift Source: https://currencyfreaks.com/documentation.html This Swift example uses URLSession and DispatchSemaphore to make an asynchronous GET request to the currency conversion API. It prints the response or any errors. ```swift import Foundation #if canImport(FoundationNetworking) import FoundationNetworking #endif var semaphore = DispatchSemaphore (value: 0) var request = URLRequest(url: URL(string: "https://api.currencyfreaks.com/v2.0/convert/latest?from=usd&to=pkr&amount=500&apikey=YOUR_APIKEY")!,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() ``` -------------------------------- ### Fetch Latest Rates using Ruby (Net::HTTP) Source: https://currencyfreaks.com/documentation.html A Ruby example using the standard `Net::HTTP` library to fetch currency exchange rates. ```ruby require "uri" require "net/http" url = URI("https://api.currencyfreaks.com/v2.0/rates/latest?base=gbp&symbols=pkr,usd,cad,eur&apikey=YOUR_APIKEY") 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 ``` -------------------------------- ### Fetch Latest Rates using Python (http.client) Source: https://currencyfreaks.com/documentation.html A Python example using the built-in `http.client` module to retrieve currency exchange rates. ```python import http.client conn = http.client.HTTPSConnection("api.currencyfreaks.com") payload = '' headers = {} conn.request("GET", "/v2.0/rates/latest?base=gbp&symbols=pkr,usd,cad,eur&apikey=YOUR_APIKEY", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` -------------------------------- ### Fetch Historical Rates using Java Source: https://currencyfreaks.com/documentation.html This Java example demonstrates how to fetch historical currency rates using OkHttpClient. You will need to include the OkHttpClient library in your project. ```java OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.currencyfreaks.com/v2.0/rates/historical?date=2022-03-20&base=gbp&symbols=usd,eur,pkr,cad&apikey=YOUR_APIKEY") .get() .build(); Response response = client.newCall(request).execute(); ``` -------------------------------- ### Call Currency Conversion Endpoint with JavaScript (Fetch) Source: https://currencyfreaks.com/documentation.html This JavaScript example uses the Fetch API to make a GET request to the currency conversion endpoint. It handles the response and logs any errors. ```javascript var requestOptions = { method: 'GET', redirect: 'follow' }; fetch("https://api.currencyfreaks.com/v2.0/convert/latest?from=usd&to=pkr&amount=500&apikey=YOUR_APIKEY", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` -------------------------------- ### Fetch Time Series Rates using C (libcurl) Source: https://currencyfreaks.com/documentation.html This C example uses libcurl to make a GET request for time series currency exchange rates. It initializes curl, sets options, performs the request, and cleans up. ```c CURL *curl; CURLcode res; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET"); curl_easy_setopt(curl, CURLOPT_URL, "https://api.currencyfreaks.com/v2.0/timeseries?startDate=2022-06-01&endDate=2022-06-07&base=eur&symbols=pkr,usd,gbp,cad&apikey=YOUR_APIKEY"); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https"); struct curl_slist *headers = NULL; curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); res = curl_easy_perform(curl); } curl_easy_cleanup(curl); ``` -------------------------------- ### Fetch Time Series Rates using C# (RestClient) Source: https://currencyfreaks.com/documentation.html This C# example uses RestClient to make a GET request for time series currency exchange rates. It sets a timeout and prints the content of the response. ```csharp var client = new RestClient("https://api.currencyfreaks.com/v2.0/timeseries?startDate=2022-06-01&endDate=2022-06-07&base=eur&symbols=pkr,usd,gbp,cad&apikey=YOUR_APIKEY"); client.Timeout = -1; var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); ``` -------------------------------- ### C# RestClient for Fluctuation Data Source: https://currencyfreaks.com/documentation.html Example of fetching fluctuation data using C# with RestClient. This code sets up a GET request and prints the content of the response. ```csharp var client = new RestClient("https://api.currencyfreaks.com/v2.0/iptocurrency?from=gbp&amount=500&ip=182.186.18.9&apikey=YOUR_APIKEY"); client.Timeout = -1; var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); ``` -------------------------------- ### Fetch Latest Rates using JavaScript (fetch) Source: https://currencyfreaks.com/documentation.html This JavaScript example uses the `fetch` API to retrieve currency rates. It handles the response as text. ```javascript var requestOptions = { method: 'GET', redirect: 'follow' }; fetch("https://api.currencyfreaks.com/v2.0/rates/latest?base=gbp&symbols=pkr,usd,cad,eur&apikey=YOUR_APIKEY", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` -------------------------------- ### Call Currency Conversion Endpoint with C# (RestClient) Source: https://currencyfreaks.com/documentation.html This C# example uses RestClient to perform a GET request to the currency conversion API. Ensure RestSharp is added to your project. ```csharp var client = new RestClient("https://api.currencyfreaks.com/v2.0/convert/latest?from=usd&to=pkr&amount=500&apikey=YOUR_APIKEY"); client.Timeout = -1; var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); ``` -------------------------------- ### Fetch Latest Rates using Swift Source: https://currencyfreaks.com/documentation.html This Swift example uses `URLSession` to fetch currency exchange rates. It includes handling for potential errors and semaphore for synchronization. ```swift import Foundation #if canImport(FoundationNetworking) import FoundationNetworking #endif var semaphore = DispatchSemaphore (value: 0) var request = URLRequest(url: URL(string: "https://api.currencyfreaks.com/v2.0/rates/latest?base=gbp&symbols=pkr,usd,cad,eur&apikey=YOUR_APIKEY")!,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() ``` -------------------------------- ### Python HTTP Request for Historical Conversion Source: https://currencyfreaks.com/documentation.html Example using Python's http.client to make a GET request for historical currency conversion. This code snippet demonstrates establishing a connection and reading the response. ```python import http.client conn = http.client.HTTPSConnection("api.currencyfreaks.com") payload = '' headers = {} conn.request("GET", "/v2.0/convert/historical?from=usd&to=pkr&amount=500&date=2022-01-10&apikey=YOUR_APIKEY", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` -------------------------------- ### Fetch Time Series Rates using PHP (cURL) Source: https://currencyfreaks.com/documentation.html This PHP example uses cURL to make a GET request for time series currency exchange rates. It configures cURL options and echoes the response. ```php 'https://api.currencyfreaks.com/v2.0/timeseries?startDate=2022-06-01&endDate=2022-06-07&base=eur&symbols=pkr,usd,gbp,cad&apikey=YOUR_APIKEY', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', )); $response = curl_exec($curl); curl_close($curl); echo $response; ?> ``` -------------------------------- ### Ruby Net::HTTP Request for Historical Conversion Source: https://currencyfreaks.com/documentation.html Example using Ruby's Net::HTTP library to make a GET request for historical currency conversion. This code snippet demonstrates parsing the URL and making the request. ```ruby require "uri" require "net/http" url = URI("https://api.currencyfreaks.com/v2.0/convert/historical?from=usd&to=pkr&amount=500&date=2022-01-10&apikey=YOUR_APIKEY") 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 ``` -------------------------------- ### Get Latest Rates (XML) Source: https://currencyfreaks.com/documentation.html Fetches the latest currency exchange rates in XML format. Append '&format=xml' to the URL parameters. Note that currency codes starting with integers will be prefixed with an underscore in XML tags. ```bash $ curl 'https://api.currencyfreaks.com/v2.0/rates/latest?apikey=YOUR_APIKEY&format=xml' 2023-03-21 12:47:00+00 USD 2.3150827642088205 2.2159199998194876 18.668821666666666 0.651985 13.217309 2068.359300493814 2.0 24.576748999999996 . <_1INCH>1.9102196752626552 . . . ``` -------------------------------- ### Fetch Historical Rates using Swift Source: https://currencyfreaks.com/documentation.html This Swift example uses URLSession and DispatchSemaphore to fetch historical currency rates. It handles potential errors and prints the response. ```swift import Foundation #if canImport(FoundationNetworking) import FoundationNetworking #endif var semaphore = DispatchSemaphore (value: 0) var request = URLRequest(url: URL(string: "https://api.currencyfreaks.com/v2.0/rates/historical?date=2022-03-20&base=gbp&symbols=usd,eur,pkr,cad&apikey=YOUR_APIKEY")!,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() ``` -------------------------------- ### Ruby Net::HTTP Request for Fluctuation Data Source: https://currencyfreaks.com/documentation.html Fetch fluctuation data using Ruby's built-in Net::HTTP library. This example constructs a URL and performs a GET request, printing the response body. ```ruby require "uri" require "net/http" url = URI("https://api.currencyfreaks.com/v2.0/iptocurrency?from=gbp&amount=500&ip=182.186.18.9&apikey=YOUR_APIKEY") 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 ``` -------------------------------- ### Get Currency Fluctuations using Ruby Source: https://currencyfreaks.com/documentation.html This Ruby snippet demonstrates how to fetch fluctuation data by making an HTTP GET request to the API using the Net::HTTP library. It prints the response body. ```Ruby require "uri" require "net/http" url = URI("https://api.currencyfreaks.com/v2.0/fluctuation?startDate=2022-10-01&endDate=2022-10-15&symbols=pkr,eur,gbp,cad&base=usd&apikey=YOUR_APIKEY") 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 ``` -------------------------------- ### Call Currency Conversion Endpoint with PHP Source: https://currencyfreaks.com/documentation.html This PHP example uses cURL to fetch currency conversion data. It sets various cURL options for the request. ```php 'https://api.currencyfreaks.com/v2.0/convert/latest?from=usd&to=pkr&amount=500&apikey=YOUR_APIKEY', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', )); $response = curl_exec($curl); curl_close($curl); echo $response; ?> ``` -------------------------------- ### Java OkHttp Request for Historical Conversion Source: https://currencyfreaks.com/documentation.html Example using Java's OkHttpClient to perform a historical currency conversion. This snippet shows how to build and execute the request. ```java OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.currencyfreaks.com/v2.0/convert/historical?from=usd&to=pkr&amount=500&date=2022-01-10&apikey=YOUR_APIKEY") .get() .build(); Response response = client.newCall(request).execute(); ``` -------------------------------- ### Historical Rates Response Example Source: https://currencyfreaks.com/documentation.html This is an example of the JSON response you will receive when querying the historical rates endpoint. It includes the requested date, base currency, and a list of historical rates for various symbols. ```json { "date": "2022-03-20", "base": "USD", "rates": { "FJD": "2.1176", "MATIC": "0.6832001093120175", "MXN": "20.385892", "STD": "21382.190504", "SCR": "14.408136", "CDF": "2005.74861", "BBD": "2.0", "HNL": "24.411536", "UGX": "3583.338449", "ZAR": "14.9602", "STN": "22.425165", . . . } } ``` -------------------------------- ### Get Currency Fluctuations using Python Source: https://currencyfreaks.com/documentation.html This Python snippet shows how to use the http.client library to connect to the API and retrieve fluctuation data. It prints the decoded response. ```Python import http.client conn = http.client.HTTPSConnection("api.currencyfreaks.com") payload = '' headers = {} conn.request("GET", "/v2.0/fluctuation?startDate=2022-10-01&endDate=2022-10-15&symbols=pkr,eur,gbp,cad&base=usd&apikey=YOUR_APIKEY", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` -------------------------------- ### Call Currency Conversion Endpoint with cURL Source: https://currencyfreaks.com/documentation.html Use this cURL command to make a GET request to the currency conversion endpoint. Replace YOUR_APIKEY with your actual API key. ```shell curl --location --request GET 'https://api.currencyfreaks.com/v2.0/convert/latest?from=usd&to=pkr&amount=500&apikey=YOUR_APIKEY' ``` -------------------------------- ### Get Latest Rates (JSON) Source: https://currencyfreaks.com/documentation.html Fetches the latest currency exchange rates in JSON format. Requires an API key. JSON is the default response format. ```bash $ curl 'https://api.currencyfreaks.com/v2.0/rates/latest?apikey=YOUR_APIKEY' { "date": "2023-03-21 12:43:00+00", "base": "USD", "rates": { "AGLD": "2.3263929277654998", "FJD": "2.21592", "MXN": "18.670707655673546", "LVL": "0.651918", "SCR": "13.21713243157135", "CDF": "2068.490771", "BBD": "2.0", "HNL": "24.57644632001569", . . . } } ``` -------------------------------- ### CURL Request for Historical Conversion Source: https://currencyfreaks.com/documentation.html Example using cURL to perform a historical currency conversion. This demonstrates the required query parameters: apikey, date, from, to, and amount. ```curl curl --location --request GET 'https://api.currencyfreaks.com/v2.0/convert/historical?from=usd&to=pkr&amount=500&date=2022-01-10&apikey=YOUR_APIKEY' ``` -------------------------------- ### Go HTTP Client for Fluctuation Data Source: https://currencyfreaks.com/documentation.html This Go program demonstrates how to make an HTTP GET request to the Fluctuation Endpoint. It handles potential errors during the request and response reading. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://api.currencyfreaks.com/v2.0/iptocurrency?from=gbp&amount=500&ip=182.186.18.9&apikey=YOUR_APIKEY" 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)) } ``` -------------------------------- ### Fetch Latest Rates using cURL Source: https://currencyfreaks.com/documentation.html Use this cURL command to make a GET request to the latest rates endpoint. Replace YOUR_APIKEY with your actual API key. ```shell curl --location --request GET 'https://api.currencyfreaks.com/v2.0/rates/latest?apikey=YOUR_APIKEY&symbols=pkr,usd,cad,eur&base=gbp' ``` -------------------------------- ### Fetch Historical Rates using Go Source: https://currencyfreaks.com/documentation.html This Go example demonstrates how to fetch historical currency rates using the standard net/http package. It reads and prints the response body. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://api.currencyfreaks.com/v2.0/rates/historical?date=2022-03-20&base=gbp&symbols=usd,eur,pkr,cad&apikey=YOUR_APIKEY" 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)) } ``` -------------------------------- ### Fetch Time Series Rates using Go Source: https://currencyfreaks.com/documentation.html This Go example demonstrates how to fetch time series currency exchange rates using the standard net/http package. It reads and prints the response body. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://api.currencyfreaks.com/v2.0/timeseries?startDate=2022-06-01&endDate=2022-06-07&base=eur&symbols=pkr,usd,gbp,cad&apikey=YOUR_APIKEY" 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)) } ``` -------------------------------- ### JavaScript Fetch API Request for Historical Conversion Source: https://currencyfreaks.com/documentation.html Example using the Fetch API in JavaScript to perform a historical currency conversion. This snippet shows basic request options. ```javascript var requestOptions = { method: 'GET', redirect: 'follow' }; ``` -------------------------------- ### GET /v2.0/fluctuation Source: https://currencyfreaks.com/documentation.html Retrieves currency fluctuation data between a specified start and end date for given symbols and a base currency. ```APIDOC ## GET /v2.0/fluctuation ### Description Retrieves currency fluctuation data between a specified start and end date for given symbols and a base currency. ### Method GET ### Endpoint https://api.currencyfreaks.com/v2.0/fluctuation ### Parameters #### Query Parameters - **startDate** (string) - Required - The start date for the fluctuation data (YYYY-MM-DD). - **endDate** (string) - Required - The end date for the fluctuation data (YYYY-MM-DD). - **symbols** (string) - Required - A comma-separated list of currency symbols to retrieve data for (e.g., pkr,eur,gbp,cad). - **base** (string) - Required - The base currency symbol (e.g., usd). - **apikey** (string) - Required - Your unique API key for authentication. ### Request Example ```json { "example": "https://api.currencyfreaks.com/v2.0/fluctuation?startDate=2022-10-01&endDate=2022-10-15&symbols=pkr,eur,gbp,cad&base=usd&apikey=YOUR_APIKEY" } ``` ### Response #### Success Response (200) - **body** (string) - The fluctuation data in string format. ``` -------------------------------- ### GET /v2.0/fluctuation Source: https://currencyfreaks.com/documentation.html Retrieves daily fluctuation data for specified currencies between a start and end date. This endpoint requires a Professional plan or higher. ```APIDOC ## GET /v2.0/fluctuation ### Description This endpoint provides information about how currencies fluctuate on a day-to-day basis. To use this feature, provide a “startDate” and “endDate” as the query parameter and choose which currencies (symbols) you would like to query. ### Method GET ### Endpoint https://api.currencyfreaks.com/v2.0/fluctuation ### Parameters #### Query Parameters - **apikey** (string) - Required - A unique key assigned to each API account used to authenticate with the API. - **startDate** (string) - Required - The start date of your preferred time frame (YYYY-MM-DD). - **endDate** (string) - Optional - The end date of your preferred time frame (YYYY-MM-DD). (Default: Day before current date). - **base** (string) - Optional - The currency code to set as the base currency (Default: USD). - **symbols** (string) - Optional - A comma-separated list of currency codes to query. ### Request Example ```json { "startDate": "2022-10-01", "endDate": "2022-10-15", "base": "GBP", "symbols": "PKR" } ``` ### Response #### Success Response (200) - **startDate** (string) - The start date of the query. - **endDate** (string) - The end date of the query. - **base** (string) - The base currency used for the query. - **rateFluctuations** (object) - An object containing fluctuation data for each queried symbol. - **[CURRENCY_SYMBOL]** (object) - Details for a specific currency. - **startRate** (string) - The currency rate at the start date. - **endRate** (string) - The currency rate at the end date. - **change** (string) - The absolute change in rate. - **percentChange** (string) - The percentage change in rate. #### Response Example ```json { "startDate": "2022-10-01", "endDate": "2022-10-15", "base": "GBP", "rateFluctuations": { "PKR": { "startRate": "254.331", "endRate": "243.874", "change": "10.457", "percentChange": "4.11" } } } ``` ``` -------------------------------- ### Fetch Latest Rates using Go Source: https://currencyfreaks.com/documentation.html A Go program demonstrating how to fetch currency exchange rates using the standard `net/http` package. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://api.currencyfreaks.com/v2.0/rates/latest?base=gbp&symbols=pkr,usd,cad,eur&apikey=YOUR_APIKEY" 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)) } ``` -------------------------------- ### Call Currency Conversion Endpoint with Java (OkHttp) Source: https://currencyfreaks.com/documentation.html This Java example demonstrates how to call the currency conversion API using the OkHttp client. Ensure OkHttp is included in your project dependencies. ```java OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.currencyfreaks.com/v2.0/convert/latest?from=usd&to=pkr&amount=500&apikey=YOUR_APIKEY") .get() .build(); Response response = client.newCall(request).execute(); ``` -------------------------------- ### Fetch Latest Rates using PHP (cURL) Source: https://currencyfreaks.com/documentation.html This PHP script utilizes cURL to make a GET request to the currency rates API. Ensure cURL is enabled in your PHP installation. ```php 'https://api.currencyfreaks.com/v2.0/rates/latest?base=gbp&symbols=pkr,usd,cad,eur&apikey=YOUR_APIKEY', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', )); $response = curl_exec($curl); curl_close($curl); echo $response; ?> ``` -------------------------------- ### Fetch Time Series Rates using Python (http.client) Source: https://currencyfreaks.com/documentation.html This Python example uses the built-in http.client library to fetch time series currency exchange rates. It establishes an HTTPS connection and reads the response body. ```python import http.client conn = http.client.HTTPSConnection("api.currencyfreaks.com") payload = '' headers = {} conn.request("GET", "/v2.0/timeseries?startDate=2022-06-01&endDate=2022-06-07&base=eur&symbols=pkr,usd,gbp,cad&apikey=YOUR_APIKEY", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` -------------------------------- ### Time Series Endpoint Response Example Source: https://currencyfreaks.com/documentation.html This JSON object represents the response from the time series endpoint, showing the historical rates for the requested currency pairs between the specified start and end dates. ```json { "startDate": "2022-06-01", "endDate": "2022-06-07", "base": "EUR", "historicalRatesList": [ { "date": "2022-06-01", "rates": { "PKR": "210.58073648790247", "USD": "1.0651300000000001" } }, { "date": "2022-06-02", "rates": { "PKR": "212.41441993262268", "USD": "1.07504" } }, { "date": "2022-06-03", "rates": { "PKR": "211.80743999999882", "USD": "1.0719" } }, { "date": "2022-06-04", "rates": { "PKR": "212.3705498572507", "USD": "1.0719" } }, { "date": "2022-06-05", "rates": { "PKR": "212.49419555477172", "USD": "1.0725240781655547" } }, { "date": "2022-06-06", "rates": { "PKR": "213.19503849443953", "USD": "1.06928999144568" } }, { "date": "2022-06-07", "rates": { "PKR": "215.71624763798502", "USD": "1.0696700000000001" } } ] } ``` -------------------------------- ### Convert Currency using Latest Rates Source: https://currencyfreaks.com/documentation.html Use this endpoint to convert any amount from one currency to another. Provide 'from', 'to' currencies, and optionally 'amount' as query parameters. This endpoint is available on paid plans only. ```bash $ curl 'https://api.currencyfreaks.com/v2.0/convert/latest?apikey=YOUR_APIKEY&from=USD&to=PKR&amount=500' ``` ```json { "date": "2023-03-21 15:22:00+00", "from": "USD", "to": "PKR", "rate": "281.683", "givenAmount": "500.0", "convertedAmount": "140841.475" } ``` -------------------------------- ### IP to Currency Conversion using Python http.client Source: https://currencyfreaks.com/documentation.html Fetch localized currency rates using Python's http.client. Replace YOUR_APIKEY and adjust parameters as needed. ```python import http.client ``` -------------------------------- ### IP to Currency Conversion using Java OkHttpClient Source: https://currencyfreaks.com/documentation.html Implement IP-based currency conversion in Java using OkHttpClient. Remember to replace YOUR_APIKEY with your actual API key. ```java OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.currencyfreaks.com/v2.0/iptocurrency?from=gbp&amount=500&ip=182.186.18.9&apikey=YOUR_APIKEY") .get() .build(); Response response = client.newCall(request).execute(); ``` -------------------------------- ### Get Latest Rates (XML) Source: https://currencyfreaks.com/documentation.html This endpoint retrieves the latest currency exchange rates in XML format. To get an XML response, append `format=xml` to the URL parameters. ```APIDOC ## GET /rates/latest (XML) ### Description Retrieves the latest currency exchange rates in XML format. ### Method GET ### Endpoint `https://api.currencyfreaks.com/v2.0/rates/latest` ### Parameters #### Query Parameters - **apikey** (string) - Required - Your API key for authentication. - **format** (string) - Optional - Set to `xml` to receive the response in XML format. ### Request Example ```bash curl 'https://api.currencyfreaks.com/v2.0/rates/latest?apikey=YOUR_APIKEY&format=xml' ``` ### Response #### Success Response (200) - **date** (string) - The date and time of the exchange rates. - **base** (string) - The base currency. - **rates** (object) - An object containing currency codes as keys and their corresponding exchange rates as values. Note: Currency codes starting with integers will be preceded by an underscore `_` in XML tags. ```