Getting Started

VatZen is Deprecated since January 2022 and API server will be shut down soon!

In this example we'll go through implementing several Rates endpoint's capabilities in different programming languages. You'll also see that some languages already have pre-built libraries which you can install for faster application development.

Note that the API key in each code block must be replaced with the unique public key found in your dashboard.

Plain JavaScript

In this section, we'll implement rates API on plain JavaScript without using provided npm module.

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