FacturAPI Unofficial Python client
This is an unofficial Python wrapper for FacturAPI
FacturAPI makes it easy for developers to generate valid Invoices in Mexico (known as Factura Electrónica or CFDI).
If you've ever used Stripe or Conekta, you'll find FacturAPI very straightforward to understand and integrate in your server app.
Install
pip install facturapi-python
Getting started
Create a customer
from facturapi import Facturapi
api = facturapi("FACTURAPI_SECRET_KEY")
new_customer = api.customers.create({
"legal_name": "Dunder Mifflin",
"tax_id": "ABC101010111",
"tax_system": "601",
"email": "email@example.com",
"phone": 6474010101,
"address": {
"street": "Blvd. Atardecer",
"exterior": 142,
"interior": 4,
"neighborhood": "Centro",
"city": "Huatabampo",
"municipality": "Huatabampo",
"zip": 86500,
"state": "Sonora",
"country": "MEX"
}
})
Create a product
from facturapi import Facturapi
api = facturapi("FACTURAPI_SECRET_KEY")
new_product = api.products.create({
"description": "Ukelele",
"product_key": 60131324,
"price": 345.6,
"tax_included": true,
"taxability": "01",
"taxes": [{
"type": "IVA",
"rate": 0.16
}],
"local_taxes": [],
"unit_key": "H87",
"unit_name": "Elemento",
"sku": "string"
})
Create an invoice
from facturapi import Facturapi
api = facturapi("FACTURAPI_SECRET_KEY")
new_invoice = api.invoices.create({
"customer": "YOUR_CUSTOMER_ID", # You can also use a customer object instead
"payment_form": api.catalogs.payment_forms.TRANSFERENCIA_ELECTRONICA,
"items": [{
"quantity": 1,
"product": 'YOUR_PRODUCT_ID' # You can also use a product object instead
}]
})
Download your invoice
from facturapi import Facturapi
api = facturapi("FACTURAPI_SECRET_KEY")
with open("invoice.zip", "wb") as binary_file:
invoice = api.invoices.download_zip("INVOICE_ID")
binary_file.write(invoice)
Send your invoice by email
from facturapi import Facturapi
api = facturapi("FACTURAPI_SECRET_KEY")
message = api.invoices.send_by_email("INVOICE_ID", "customer@email.com")
Documentation
You can find more on what to do on the official documentation
Help
:warning: This is an unofficial project, the maintainers does not have any affiliation with FacturAPI or their developers. Any error with the service itself should be reported to the official support channels
Found a bug?
If you find a bug for this API client, please create an issue on the project's github page
Contribute
All PRs are welcome!
Release files for facturapi-python 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| facturapi_python-0.1.4.tar.gz | 15.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| facturapi_python-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 36.6 kB
Release files / facturapi_python-0.1.4.tar.gz
| Download URL | facturapi_python-0.1.4.tar.gz |
|---|---|
| Size | 15.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a71fed4782e5ee9bd4f7bcef0004d37fdaaf0b88dcfbc22b84682a0ef546d2d
|
|
BLAKE2b-256 checksum How to use checksums |
217f080574b5ace5468db47113d1ca43432142dbf73d8bd2cd9979d8984f27b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.15
|
Release files / facturapi_python-0.1.4-py3-none-any.whl
| Download URL | facturapi_python-0.1.4-py3-none-any.whl |
|---|---|
| Size | 21.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6388ebd2b385fd7ce033308e88ace063e63e57456cd660d5972a0b9128ef69aa
|
|
BLAKE2b-256 checksum How to use checksums |
2a51940b253d17df4ff6cef520aa221e340da994c5fb8d4942b63f85f04bb4a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.15
|