The `viesapi-client` is the official JavaScript library for interacting with the VIES API, which provides services for querying the European Union's VAT Information Exchange System. This client enables developers to validate EU VAT numbers, retrieve company details, and check the registration status of businesses across all EU member states. Currently at version 1.3.3, the library is actively maintained with regular updates and ships with full TypeScript type definitions. It supports both Node.js and browser environments, offering built-in authentication, request signing, and comprehensive error handling. Key differentiators include its ability to perform both synchronous single-number lookups and asynchronous batch processing, along with utility functions for local validation of EU VAT and Polish NIP numbers prior to making API requests. The library handles the intricacies of communicating with the VIES system, simplifying the process for developers.
npm install viesapi-clientVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to instantiate the `VIESAPIClient` for both test and production environments, perform local VAT number validation, and then query the VIES API to check the status of an EU VAT number, including basic error handling.
Register for an account on viesapi.eu to obtain your API ID and Key. Pass them as arguments to the `VIESAPIClient` constructor: `new VIESAPIClient(apiId, apiKey);`. Store credentials securely, e.g., using environment variables.
Use the parameter-less constructor `new VIESAPIClient()` for the test environment. Refer to the VIES API documentation for the list of valid test VAT numbers, such as 'PL7171642051' or 'DE327990207'.
Always ensure the VAT number string includes the correct two-letter country code prefix, e.g., `client.getVIESData('PL7171642051')`.Implement proper error handling for rate limit responses (e.g., HTTP 429 Too Many Requests) and consider implementing a back-off strategy or caching successful results. Review your service plan details for specific rate limits.
Ensure you have registered on viesapi.eu and are using the correct API ID and Key for the production client. Double-check for typos and ensure the keys are for the correct environment (test vs. production).
For CommonJS, use `const { VIESAPIClient } = require('viesapi-client');` or `const VIESAPI = require('viesapi-client'); const client = new VIESAPI.VIESAPIClient();`. For ES Modules, ensure you are using `import { VIESAPIClient } from 'viesapi-client';`.Verify your internet connection. Check if the VIES API service is online. If running in a Node.js environment, ensure there are no proxy or firewall settings blocking outbound connections to `viesapi.eu`.
Prepend the correct two-letter country code to the VAT number (e.g., 'DE123456789' for Germany). Utilize `EUVAT.isValid()` for client-side format validation before making API calls.
No dependency data recorded yet.