Code Samples For Instant Integration
PHP Code Example
Below sample is only for the latest price endpoint. You can visit our documentation page for other endpoints and edit this sample code for other endspoints.
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://currencydatafeed.com/api/data.php?currency=EUR/USD+XAU/USD',
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',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer YOUR ACCESS TOKEN'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
NodeJs Code Example
Below sample is only for the latest price endpoint. You can visit our documentation page for other endpoints and edit this sample code for other endspoints.
var axios = require('axios');
var config = {
method: 'get',
url: 'https://currencydatafeed.com/api/data.php?currency=EUR/USD+XAU/USD',
headers: {
'Authorization: Bearer YOUR ACCESS TOKEN'
}
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Javascript - Jquery Ajax
Below sample is only for the latest price endpoint. You can visit our documentation page for other endpoints and edit this sample code for other endspoints.
var settings = {
"url": "https://currencydatafeed.com/api/data.php?currency=EUR/USD+XAU/USD",
"method": "GET",
"timeout": 0,
"headers": {
"Authorization": "Bearer YOUR ACCESS TOKEN"
},
};
$.ajax(settings).done(function (response) {
console.log(response);
});
Python
Below sample is only for the latest price endpoint. You can visit our documentation page for other endpoints and edit this sample code for other endspoints.
import http.client
conn = http.client.HTTPSConnection("currencydatafeed.com")
payload = ''
headers = {
'Authorization': 'Bearer YOUR ACCESS TOKEN'
}
conn.request("GET", "/api/data.php?currency=EUR/USD+XAU/USD", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Ruby
Below sample is only for the latest price endpoint. You can visit our documentation page for other endpoints and edit this sample code for other endspoints.
require "uri"
require "net/http"
url = URI("https://currencydatafeed.com/api/data.php?currency=EUR/USD+XAU/USD")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer YOUR ACCESS TOKEN"
response = https.request(request)
puts response.read_body
Java - OKHTTP
Below sample is only for the latest price endpoint. You can visit our documentation page for other endpoints and edit this sample code for other endspoints.
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://currencydatafeed.com/api/data.php?currency=EUR/USD+XAU/USD")
.method("GET", null)
.addHeader("Authorization", "Bearer YOUR ACCESS TOKEN")
.build();
Response response = client.newCall(request).execute();
GO Native
Below sample is only for the latest price endpoint. You can visit our documentation page for other endpoints and edit this sample code for other endspoints.
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://currencydatafeed.com/api/data.php?currency=EUR/USD+XAU/USD"
method := "GET"
client := &http.Client {
}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Authorization", "Bearer YOUR ACCESS TOKEN")
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))
}
© 2015-2022 currencydatafeed.com - All rights reserved