Skip to content

Instantly share code, notes, and snippets.

@kgaughan
Created April 14, 2011 10:08
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save kgaughan/919221 to your computer and use it in GitHub Desktop.
Save kgaughan/919221 to your computer and use it in GitHub Desktop.
Checking an EU VAT number using the VIES SOAP interface
from suds.client import Client
client = Client('http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl')
# Returns a dict-like object with the fields 'countryCode', 'vatNumber',
# 'requestDate', 'valid' (boolean), 'name', and 'address'.
result = client.service.checkVat('IE', '6390845P')
@kgaughan
Copy link
Author

The library used above is Suds, which is one of the better Python SOAP libraries: https://fedorahosted.org/suds/wiki/Documentation

For more information on the VIES SOAP interface, see: http://ec.europa.eu/taxation_customs/vies/faqvies.do#item16

@dimitern
Copy link

Awesome example @kgaughan, just what I needed :)

@jagheterfrej
Copy link

jagheterfrej commented Aug 21, 2018

@kgaughan - I've tried using your code exactly as is, but I receive an error. I would say I am new to python, so please if possible - keep it simple. :)

Traceback (most recent call last):

File "C:\Users\nm469mz\AppData\Local\Continuum\anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2910, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)

File "", line 1, in
from suds.client import Client

File "C:\Users\nm469mz\AppData\Local\Continuum\anaconda3\lib\site-packages\suds\client.py", line 242
except Exception, e:
^
SyntaxError: invalid syntax

@xarbit
Copy link

xarbit commented Mar 5, 2019

I was having some issues with suds, so in case someone comes across this, here is my alternative:

    from zeep import Client

    # http://ec.europa.eu/taxation_customs/vies/technicalInformation.html
    client = Client('http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl')

    # Returns a dict-like object with the fields 'countryCode', 'vatNumber',
    # 'requestDate', 'valid' (boolean), 'name', and 'address'.
    result = client.service.checkVat(country, number)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment