# 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);
$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);
$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);
$response = curl_exec($ch);
curl_close($ch);
print_r($response);
// latest rates (Node.js 18+, built-in fetch)
const response = await fetch('https://api.currencyapi.com/v3/latest?apikey=YOUR-APIKEY');
if (!response.ok) {
throw new Error(`Request failed: ${response.status}`);
}
console.log(await response.json());
// latest with specific base currency (Node.js 18+, built-in fetch)
const response = await fetch('https://api.currencyapi.com/v3/latest?apikey=YOUR-APIKEY&base_currency=USD');
if (!response.ok) {
throw new Error(`Request failed: ${response.status}`);
}
console.log(await response.json());
// historical rates from a specific date (Node.js 18+, built-in fetch)
const response = await fetch('https://api.currencyapi.com/v3/historical?apikey=YOUR-APIKEY&base_currency=USD&date=2020-10-01');
if (!response.ok) {
throw new Error(`Request failed: ${response.status}`);
}
console.log(await response.json());
// latest rates
try {
String apikey = "YOUR-APIKEY";
String url = "https://api.currencyapi.com/v3/latest?apikey=" + apikey;
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?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();
}