chrj / pyvies

Validate EU VAT numbers in the VIES database using Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Installation

$ pip install pyvies

Usage

From Python:

import pyvies

# Initialize the validator with *your* VAT number

v = pyvies.Vies("DK", 12345678)

# Validate any VAT number in the EU to a dict containing these keys:
#  - "Date when request received"
#  - "Name"
#  - "Consultation Number"
#  - "Member State"
#  - "Address"
#  - "VAT Number" 

try:

    result = v.validate("GB", 12345678)

except pyvies.InvalidVATNumber, e:

    # Catch validation errors
    error = e.args[0]

except pyvies.Unavailable:

    # The database is unavailable
    pass

From the console:

$ vies <requester_country> <requester_vat> <country> <vat>

E.g.:

$ vies DK 12345678 GB 12345678

You can use the resulting error code to check for validation:

$ vies DK 12345678 GB 12345678 && echo Valid

License

LGPL

About

Validate EU VAT numbers in the VIES database using Python


Languages

Language:Python 100.0%