fetch-vat-rates
v1.0.1
Published
Fetch EU VAT rates from the official EU web service in a usable form
Readme
fetch-vat-rates
A minimal library/script to fetch and parse VAT rates from the official Taxes in Europe Database.
Because having to apply for a third-party API key or hope for someone else to manually update a JSON file is, frankly, ridiculous.
The package exports an async function fetchVatRates() that resolves with an object containing:
allRates: an array of all active VAT rates in all EU members, with category codes and decriptions.standardRates: a simple mapping of country code to VAT rate in percent, which is probably what you want.
import { fetchVatRates } from 'fetch-vat-rates';
const { allRates, standardRates } = await fetchVatRates();
console.log(standardRates.LV); // 21The functions it calls in sequence are exported as well:
export async function fetchVatRates() {
const xml = await fetchVatRateXml();
const allRates = parseVatRateXml(xml);
const standardRates = extractStandardRates(allRates);
return { allRates, standardRates };
}Command line usage
If you just need the file or want to use this outside of Node.js, you can install the package globally
npm install -g fetch-vat-ratesAnd run the included "binary" (it's not)
fetch-vat-rates > rates.jsonIt outputs the full JSON to stdout. There is no interface to speak of.
Important!
- This package does not include the actual data and will not be updated regularly unless something breaks.
- The WSDL call takes a few seconds, probably should cache this and/or put it in a cron job.
- Greece is
ELin the data returned from the service. It's copied asGRinstandardRates, butallRatesare returned as is.
License
Public Domain or CC0
