// latest rates
curl -G "https://api.currencyapi.com/v3/latest" \
-d "apikey=YOUR-KEY" \
// latest with specific base currency
curl -G "https://api.currencyapi.com/v3/latest" \
-d "apikey=YOUR-KEY" \
-d "base_currency=USD"
// historical rates from a specific date
curl -G "https://api.currencyapi.com/v3/historical" \
-d "apikey=YOUR-KEY" \
-d "base_currency=USD" \
-d "date=2020-10-01" \
// latest rates
$url = "https://api.currencyapi.com/v3/latest?apikey=YOUR-APIKEY";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
curl_close($ch);
print_r($response);
// latest with specific base currency
$url = "https://api.currencyapi.com/v3/latest?apikey=YOUR-APIKEY&base_currency=USD";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
curl_close($ch);
print_r($response);
// historical rates from a specific date
$url = "https://api.currencyapi.com/v3/historical?apikey=YOUR-APIKEY&base_currency=USD&date=2020-10-01";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
curl_close($ch);
print_r($response);
// latest rates
const request = require('request-promise');
request('https://api.currencyapi.com/v3/latest?apikey=YOUR-APIKEY')
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error)
})
// latest with specific base currency
const request = require('request-promise');
request('https://api.currencyapi.com/v3/latest?apikey=YOUR-APIKEY&base_currency=USD')
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error)
})
// historical rates from a specific date
const request = require('request-promise');
request('https://api.currencyapi.com/v3/historical?apikey=YOUR-APIKEY&base_currency=USD&date=2020-10-01')
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error)
})
// latest rates
try {
String apikey = "YOUR-APIKEY";
String url = "https://api.currencyapi.com/v3/latest";
URL urlForGetRequest = new URL(url);
String readLine = null;
HttpURLConnection connection = (HttpURLConnection) urlForGetRequest.openConnection();
connection.setRequestMethod("GET");
int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
StringBuffer response = new StringBuffer();
while ((readLine = in.readLine()) != null) {
response.append(readLine);
}
in.close();
System.out.println(response.toString());
} else {
throw new Exception("Error in API Call");
}
} catch (Exception ex) {
ex.printStackTrace();
}
// latest with specific base currency
try {
String apikey = 'YOUR-APIKEY';
String url = "https://api.currencyapi.com/v3/latest?apikey=" + apikey + "&base_currency=USD";
URL urlForGetRequest = new URL(url);
String readLine = null;
HttpURLConnection connection = (HttpURLConnection) urlForGetRequest.openConnection();
connection.setRequestMethod("GET");
int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
StringBuffer response = new StringBuffer();
while ((readLine = in.readLine()) != null) {
response.append(readLine);
}
in.close();
System.out.println(response.toString());
} else {
throw new Exception("Error in API Call");
}
} catch (Exception ex) {
ex.printStackTrace();
}
// historical rates from a specific date
try {
String apikey = "YOUR-APIKEY";
String url = "https://api.currencyapi.com/v3/historical/historical?apikey=" + apikey + &base_currency=USD&date=2020-10-01";
URL urlForGetRequest = new URL(url);
String readLine = null;
HttpURLConnection connection = (HttpURLConnection) urlForGetRequest.openConnection();
connection.setRequestMethod("GET");
int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
StringBuffer response = new StringBuffer();
while ((readLine = in.readLine()) != null) {
response.append(readLine);
}
in.close();
System.out.println(response.toString());
} else {
throw new Exception("Error in API Call");
}
} catch (Exception ex) {
ex.printStackTrace();
}