Factura Electrónica AFIP y otros servicios web (proyecto software libre) — Interfases, tools and apps for Argentina's gov't. webservices (soap, com/dll simil-ocx, pdf, dbf, xml, json, etc.) #python
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
conf Agrego DigiCert Global Root CA (para padrón/aws) Jan 26, 2018
datos PyRece: soporte para campos opcionales (RG4004, 3668, 3411, etc.) Aug 26, 2017
ejemplos WSRemCarne: agrego ejemplo para Visual Fox Pro (VFP) Oct 25, 2018
formatos Ajuste menor a formato DBF de intercambio (advertencia/encoding) Oct 1, 2016
plantillas agrego logo pyafipws Jul 2, 2015
src muevo el codigo fuente de la biblioteca en .C a su respectivo directorio Jan 8, 2014
tests WSLTV: procesar respuesta liquidacion Feb 6, 2016
typelib Actualizo libreria de tipos: Sep 24, 2016
.gitignore Initial commit Jul 30, 2013
.hgtags Added tag 2.7.1872 for changeset d072fbbc4803 Sep 10, 2016
LICENSE Initial commit Jul 30, 2013
README.md Fix #30 (updated JAIIO paper link) Feb 18, 2018
__init__.py Ajusto leyenda copyright licencia (año) Jan 20, 2015
cot.py COT: ajusto conversion unicode URL cliente web (aplicativo visual) Jun 9, 2015
cot.pyw COT: ajusto version y locale (app visual GUI) May 27, 2015
iibb.py WSRemCarne: agrego ejemplo Visual Basic script Oct 20, 2018
licencia.txt Ajusto leyenda copyright licencia (año) Jan 20, 2015
nsis.py WSRemCarne: agrego ejemplo Visual Basic script Oct 20, 2018
padron.py Merge pull request #21 from oscarvogel/actualiza-padron Feb 18, 2018
pyemail.py PyEMAIL: ajusto conversion unicode -> string Jun 27, 2015
pyfepdf.py Merge pull request #1 from reingart/master Dec 19, 2017
pyi25.py PyI25: ajustes instalador y ejemplo VB scrpiting Dec 31, 2016
pyrece.py PyRece: soporte para SMTP Start TLS Apr 17, 2018
pyrece.rsrc.py PyRece: agrego panel de fondo (windows) Jun 10, 2015
rece1.py Merge pull request #1 from reingart/master Dec 19, 2017
receb1.py RECEB1: agrego soporte para tablas DBF Jan 18, 2017
recem.py Completo limpieza modulos antiguos Oct 5, 2016
recet.py RECET: nro_doc alfanumerico (pasaportes) Jul 19, 2017
recex1.py RECEXv1: agrego timeout y proxy Jan 26, 2018
requirements.txt Actualizo requerimiento biblioteca SOAP Dec 19, 2017
rg3685.py RG3685: reg. info. compras y ventas (conv. RECE1) Apr 6, 2016
setup.bat Agrego scripts instalación automatizada en windows Jan 29, 2015
setup.py WSRemCarne: agrego ejemplo Visual Basic script Oct 20, 2018
sired.py RG3685: reg. info. compras y ventas (conv. RECE1) Apr 6, 2016
trazafito.py WSLPG y Trazabilidad: agrego timeout predeterminado (30 segundos) Aug 18, 2015
trazamed.py TrazaMed: mostrar contenido de archivos de intercambio (para depuración) Jul 7, 2017
trazaprodmed.py TrazaProdMed: ajustes para pruebas/ejemplo Dec 24, 2016
trazarenpre.py TrazaRenpre: fix #42: parámetro Paso de frontera Aug 28, 2018
trazavet.py WSLPG y Trazabilidad: agrego timeout predeterminado (30 segundos) Aug 18, 2015
utils.py Utils: ajuste version SSL WebClient (SO antiguos) Oct 7, 2018
venv.bat Agrego scripts instalación automatizada en windows Jan 29, 2015
wdigdepfiel.py Completo limpieza modulos antiguos Oct 5, 2016
ws_sr_padron.py WS_SR_PADRON: ajuste constante homologación Sep 13, 2018
wsaa.py WSRemCarne: agrego ejemplo Visual Basic script Oct 20, 2018
wsbfev1.py WSBFEv1: ajusto mensaje de error opcional (GetParamNCM) Jan 18, 2017
wscdc.py WSCDC: ajusto datos de prueba Jun 22, 2015
wscoc.py WSLPG y Trazabilidad: agrego timeout predeterminado (30 segundos) Aug 18, 2015
wsct.py WSCT: deshabilitar homologación Dec 29, 2017
wsctg.py WSCTG: ajuste anulacion Sep 12, 2018
wsfev1.py WSRemCarne: agrego ejemplo Visual Basic script Oct 20, 2018
wsfexv1.py Merge pull request #19 from jjscarafia/master Feb 18, 2018
wslpg.py WSLPG: agrego TIMEOUT a la config Oct 7, 2018
wslpg_datos.py WSLPG: ajusto datos de prueba y datos PDF (LPG) May 13, 2015
wslsp.py WSRemCarne: agrego ejemplo Visual Basic script Oct 20, 2018
wsltv.py WSLTV: no reintentar y timeout configurable May 5, 2018
wslum.py WSLUM: ajusto ajuste (formulario papel y/o cae) Jan 4, 2017
wsmtx.py WSMTX: agrego Cuit a Comprobante Asociado por Revison v0.5 AFIP Mar 16, 2017
wsremcarne.py WSRemCarne: Consultar Codigos Domicilio Oct 24, 2018



PyAfipWs contains Python modules to operate with web services regarding AFIP (Argentina's "IRS") and other government agencies, mainly related to electronic invoicing, several taxes and traceability.

Copyright 2008 - 2016 (C) Mariano Reingart reingart@gmail.com (creator and maintainter). All rights reserved.

License: GPLv3+, with "commercial" exception available to include it and distribute with propietary programs

General Information:

More information at Python Argentina Magazine article (English) and JAIIO 2012 paper (Spanish)

Project Structure:

  • Python library (a helper class for each webservice for easy use of their methods and attributes)
  • PyAfipWs: OCX-like Windows Component-Object-Model interface compatible with legacy programming languages (VB, VFP, Delphi, PHP, VB.NET, etc.)
  • LibPyAfipWs: DLL/.so compiled shared library (exposing python methods to C/C++/C#)
  • Console (command line) tools using simplified input & ouput files (TXT, DBF, JSON)
  • PyRece GUI and FacturaLibre WEB apps as complete reference implementations
  • Examples for Java, .NET (C#, VB.NET), Visual Basic, Visual Fox Pro, Delphi, C, PHP.
  • Minor code fragment samples for SAP (ABAP), PowerBuilder, Fujitsu Net Cobol, Clarion, etc.
  • Modules for OpenERP/Odoo - Tryton

Features implemented:

  • Supported alternate interchange formats: TXT (fixed lenght COBOL), CSV, DBF (Clipper/xBase/Harbour), XML, JSON, etc.
  • Full automation to request authentication and invoice authorization (CAE, COE, etc.)
  • Advanced XML manipulation, caching and proxy support.
  • Customizable PDF generation and visual designer (CSV templates)
  • Email, barcodes (PIL), installation (NSIS), configuration (.INI), debugging and other misc utilities

Web services supported so far:


  • WSAA: authorization & authentication, including digital cryptographic signature
  • WSFEv1: domestic market (electronic invoice) -English-
  • WSMTXCA: domestic market (electronic invoice) -detailing articles and barcodes-
  • WSCT: tourism (electronic invoice) -"tax free" VAT refund for tourists-
  • WSBFEv1: tax bonus (electronic invoice)
  • WSFEXv1: foreign trade (electronic invoice) -English-
  • WSCTG: agriculture (grain traceability code)
  • WSLPG: agriculture (grain liquidation - invoice)
  • WSLTV: agriculture (green tobacco - invoice)
  • WSLUM: agriculture (milk - invoice)
  • WSLSP: agriculture (cattle/livestock - invoice)
  • wDigDepFiel: customs (faithful depositary)
  • WSCOC: currency exchange operations autorization
  • WSCDC: invoice verification
  • Taxpayers' Registe: database to check sellers and buyers register


  • COT: Provincial Operation Transport Code (aka electronic Shipping note)


  • TrazaMed: National Medical Drug Traceability Program
  • TrazaRenpre: Controlled Chemical Precursors Traceability Program
  • TrazaFito: Phytosanitary Products Traceability Program

Installation Instructions:


On Ubuntu (GNU/Linux), you will need to install httplib2 and openssl binding. Then you can download the compressed file, unzip it and use:

sudo apt-get install python-httplib2 python-m2crypto
wget https://github.com/reingart/pyafipws/archive/master.zip
unzip master.zip
cd pyafipws-master
sudo pip install -r requirements.txt

Note: M2Crypto is optional, the library will use OpenSSL directly (using subprocess)

You'll need a digital certificate (.crt) and private key (.key) to authenticate (see certificate generation for more information and instructions). Provisionally, you can use author's testing certificate/key:

wget https://www.sistemasagiles.com.ar/soft/pyafipws/reingart.zip
unzip reingart.zip

You should configure rece.ini to set up paths and URLs if using other values than defaults.

Then, you could execute WSAA script to authenticate (getting Token and Sign) and WSFEv1 to process an electronic invoice:

python wsaa.py
python wsfev1.py --prueba

With the last command, you should get the Electronic Autorization Code (CAE) for testing purposes (sample invoice data, do not use in production!).

Virtual environment (testing):

The following commands clone the repository, creates a virtualenv and install the packages there (including the latest versions of the dependencies) to avoid conflicts with other libraries:

sudo apt-get install python-dev swig python-virtualenv mercurial python-pip libssl-dev python-dulwich
hg clone git+https://github.com/reingart/pyafipws.git --config extensions.hggit=
cd pyafipws
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt

Note: For convenience, development is done using mercurial; You could use hg-git or git directly.

Dependency installation (development):

For SOAP webservices PySimpleSOAP is needed (spin-off of this library, inspired by the PHP SOAP extension):

hg clone git+https://github.com/pysimplesoap/pysimplesoap.git --config extensions.hggit=
cd pysimplesoap
hg up reingart
python setup.py install

Use "stable" branch reingart (see requirements.txt for more information)

For PDF generation, you will need the PyFPDF (PHP's FPDF library, python port):

hg clone git+https://github.com/reingart/pyfpdf.git --config extensions.hggit=
cd pyfpdf
python setup.py install

For the GUI app, you will need wxPython:

sudo apt-get install wxpython

PythonCard is being replaced by gui2py:

pip install gui2py

For the WEB app, you will need web2py.

On Windows, you can see available installers released for evaluation purposes on Download Releases

For more information see the source code installation steps in the wiki