Skip to main content

Unofficial Facturapi.io Python client

Project description

FacturAPI Unofficial Python client

PyPI - Downloads PyPI PyPI - Python Version GitHub Repo stars GitHub issues

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!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

facturapi_python-0.1.1.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

facturapi_python-0.1.1-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file facturapi_python-0.1.1.tar.gz.

File metadata

  • Download URL: facturapi_python-0.1.1.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for facturapi_python-0.1.1.tar.gz
Algorithm Hash digest
SHA256 43d84e3f5091cb5ad4601b30bf6144350e0ee266ab1dd3b7887eb110444641c3
MD5 3a6dbd5a280d840975cfb98b1f4af7de
BLAKE2b-256 0439f0eab916af27d4a39c9f8b6bc84365cac7be32d316cf43320e529f11020b

See more details on using hashes here.

File details

Details for the file facturapi_python-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for facturapi_python-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4f31b3f82df2ea6e96937f8eb04a4a35b31819573430d0ebceddb544210fab0d
MD5 31cc934a8d8069d3e1a626500d5f4bc5
BLAKE2b-256 62e89a43b35c15c5a8e1eeea810e99dc648cb7a9bb1b3711302e30099f549831

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page