This is a Python library for FacturAPI
FacturAPI makes it easy for developers to generate valid Invoices in Mexico (known as Factura Electrónica or CFDI).
This library is based on cuenca-python
💙.
Just use pip
to install de library:
pip install facturapi
Be sure to create a free account on FacturAPI and have access to your test or live API keys.
There are two ways to configure your API Key to use the library:
-
Environment variable: Just set an environment variable and the library will automatically use it:
export FACTURAPI_KEY=YOUR_API_KEY
-
Using the
configure
method: If you want to set it in the code, you can import and use theconfigure
method:from facturapi import configure configure(api_key='YOUR_API_KEY')
After configuring the API Key, you can use the client to perform many actions on the resources, for example to create a Customer:
import facturapi
from facturapi.resources.customers import CustomerRequest, CustomerUpdateRequest
customer = facturapi.Customer.create(data=CustomerRequest(
legal_name='Frida Kahlo',
tax_id='ABCD111111CBA',
email='frida_kahlo@test.com',
))
For more details on the data used to create a Customer and other resources, be sure to check out the docs.
More examples can be found on the examples directory.
You can checkout Facturapi's docs for more info on the API and its resources.
Or checkout the library's docs for usage and more technical details.
Please create an issue addressing the bug and how to replicate it.
Be sure to fork the repo and send your PR! Any and all help is appreciated. Also don't forget to keep the coverage above 98%, we love tested code!
-
Facturapi: contacto@facturapi.io
-
Cuenca: dev@cuenca.com
Developed and maintained with 💙 by Cuenca