Getting Started
Plain JavaScript
const apiKey = 'aea3661794add2e8e799ab005c2bd607';
// This function will return all available
// rates, for all EU countries
async function fetchAllRates() {
const ratesResponse = await fetch('https://api.vatzen.com/v1/rates', {
method: 'GET',
headers: {
apiKey,
}
});
if (ratesResponse.code === 200) {
return (await ratesResponse.json()).rates;
} else {
return [];
}
}
async function fetchRateByCountryCode(countryCode) {
const ratesResponse = await fetch(`https://api.vatzen.com/v1/rate?country_code=${countryCode}`, {
method: 'GET',
headers: {
apiKey,
}
});
if (ratesResponse.code === 200) {
return (await ratesResponse.json()).rate;
} else {
return [];
}
}Last updated