VatZen API (DEPRECATED, DO NOT USE)
  • Introduction
  • Getting Started
  • Authorization
  • API Errors
  • OpenAPI & Swagger UI
  • API Description
    • VAT Rates
    • VAT Number Validations
    • VAT Prices Calculations
    • Generate Invoce
  • SDKs
    • NodeJS
    • Ruby
    • Python
Powered by GitBook
On this page

Was this helpful?

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 [];
  }
}
PreviousIntroductionNextAuthorization

Last updated 3 years ago

Was this helpful?