SDKs overview
VATComply.com offers Software Development Kits (SDKs) and libraries designed to facilitate integration with its various tax compliance APIs. These tools provide language-specific interfaces for interacting with services such as VAT number validation, real-time exchange rate retrieval, and VAT rate lookups. The SDKs aim to reduce development time by handling HTTP requests, response parsing, and authentication, allowing developers to focus on application logic rather than API communication specifics. The core functionalities available through the SDKs align with the VATComply.com API reference documentation, covering endpoints for checking VAT rates, validating VAT identification numbers, and accessing currency exchange data.
Using an SDK can streamline the process of building applications that require accurate VAT calculations and validation, which is particularly relevant for e-commerce platforms and accounting software. For instance, an SDK can simplify retrieving the current VAT rate for a specific country or validating an EU VAT number against official databases, enhancing the reliability of tax calculations within an application. This approach contrasts with direct API calls, which require manual construction of request bodies and parsing of JSON responses, as described in general API development guidelines by resources like Mozilla's Fetch API documentation.
Official SDKs by language
VATComply.com provides official SDKs for several popular programming languages, ensuring broad compatibility for developers. These SDKs are maintained by VATComply.com and are designed to offer a consistent and up-to-date interface for all API functionalities. The table below summarizes the currently available official SDKs, their respective package managers, installation commands, and maturity status, as detailed in the VATComply.com documentation portal.
| Language | Package | Installation Command | Maturity |
|---|---|---|---|
| Python | vatcomply-python |
pip install vatcomply-python |
Stable |
| PHP | vatcomply/php-sdk |
composer require vatcomply/php-sdk |
Stable |
| Node.js | @vatcomply/sdk |
npm install @vatcomply/sdk |
Stable |
Each SDK is built to reflect the structure and capabilities of the VATComply.com REST API, including methods for each endpoint. For example, the Python SDK might expose methods like get_exchange_rates(), validate_vat_number(), and get_vat_rate(), wrapping the underlying HTTP requests and JSON processing. Developers can expect these SDKs to handle API key authentication, request formatting, and error handling, abstracting away the boilerplate code typically associated with API integrations.
Installation
Installing VATComply.com SDKs involves using the standard package manager for each respective language. This process typically retrieves the library from a public repository and adds it to the project's dependencies. The official VATComply.com developer documentation provides detailed, language-specific installation instructions.
Python
For Python projects, the SDK is available via PyPI. Installation is performed using pip:
pip install vatcomply-python
After installation, the library can be imported into Python scripts. It is generally recommended to use a virtual environment for Python projects to manage dependencies effectively, as described in Python's official virtual environments guide.
PHP
PHP projects typically use Composer for dependency management. The VATComply PHP SDK can be installed by running:
composer require vatcomply/php-sdk
This command adds the SDK to the vendor/ directory and updates the project's composer.json and composer.lock files. Autoloading is handled automatically by Composer, allowing classes from the SDK to be used directly in PHP code.
Node.js
Node.js applications use npm (Node Package Manager) or yarn for package installation. To install the VATComply Node.js SDK:
npm install @vatcomply/sdk
or if using yarn:
yarn add @vatcomply/sdk
Once installed, the SDK can be imported as a module in JavaScript or TypeScript files. The Node.js ecosystem benefits from modularity, and SDKs integrate seamlessly into common development workflows.
Quickstart example
The following examples demonstrate how to use the VATComply.com SDKs to perform common tasks, such as retrieving VAT exchange rates or validating a VAT number. These snippets assume that the respective SDKs have been installed and an API key is available. API keys are essential for authenticating requests and are provided upon VATComply.com account registration.
Python Quickstart: Get Exchange Rates
This Python example retrieves the latest exchange rates relative to a base currency. Replace YOUR_API_KEY with your actual VATComply.com API key.
import vatcomply
vatcomply.api_key = "YOUR_API_KEY"
try:
# Get latest exchange rates for EUR
rates = vatcomply.ExchangeRates.latest(base='EUR')
print(f"Exchange rates for EUR: {rates}")
# Get historical rates for a specific date
historical_rates = vatcomply.ExchangeRates.for_date('2023-01-01', base='USD')
print(f"Historical rates for 2023-01-01 (USD base): {historical_rates}")
except vatcomply.VatComplyError as e:
print(f"Error: {e}")
PHP Quickstart: Validate VAT Number
This PHP example demonstrates how to validate an EU VAT identification number using the SDK. This is crucial for B2B transactions within the EU.
<?php
require 'vendor/autoload.php';
use VatComply\VatComplyClient;
use VatComply\Exception\VatComplyException;
$client = new VatComplyClient('YOUR_API_KEY');
try {
$validationResult = $client->vatNumbers->validate('DE', '123456789'); // Example German VAT number
if ($validationResult['valid']) {
echo "VAT number is valid. Name: " . $validationResult['name'] . ", Address: " . $validationResult['address'] . "\n";
} else {
echo "VAT number is invalid.\n";
}
} catch (VatComplyException $e) {
echo "Error: " . $e->getMessage() . "\n";
}
?>
Node.js Quickstart: Get VAT Rate by Country
This Node.js example fetches the standard VAT rate for a specified country, useful for e-commerce checkout processes.
const VatComply = require('@vatcomply/sdk');
const client = new VatComply('YOUR_API_KEY');
async function getVatRate() {
try {
const countryCode = 'FR'; // Example: France
const vatRate = await client.vatRates.get(countryCode);
console.log(`VAT rate for ${countryCode}: ${vatRate.standard_rate}%`);
// Get VAT rates for all countries
const allVatRates = await client.vatRates.all();
console.log('All available VAT rates:', allVatRates);
} catch (error) {
console.error('Error fetching VAT rate:', error.message);
}
}
getVatRate();
These examples illustrate the basic usage patterns for each SDK. Developers can refer to specific VATComply.com language-specific SDK documentation for more advanced features, error handling strategies, and endpoint-specific parameters, ensuring comprehensive integration.
Community libraries
While VATComply.com maintains official SDKs, the broader developer community may also contribute open-source libraries or integrations. These community-driven projects can offer alternative approaches, specialized functionalities, or support for additional programming languages not covered by the official SDKs. Community libraries are typically found on platforms like GitHub or language-specific package repositories.
Developers considering community-contributed libraries should evaluate their maturity, maintenance status, and adherence to security best practices. Checking the project's issue tracker, commit history, and the reputation of the contributors can provide insights into the reliability of such resources. Although VATComply.com primarily supports its official SDKs, community contributions can sometimes offer valuable supplementary tools or serve as reference implementations for specific use cases. Developers can explore popular code repositories to identify potential community-driven SDKs or integrations that might exist for VATComply.com, often by searching for keywords like "vatcomply" combined with the desired programming language or framework.