Python SDK for Digifact FEL Guatemala e-invoicing API
Project description
Digifact FEL Guatemala — Python SDK
Python SDK for the Digifact FEL (Factura Electrónica en Línea) Guatemala e-invoicing API.
Installation
pip install digifact-sdk
Or from source:
pip install -e sdk/python/
Quick start
from digifact_sdk import DigifactClient
client = DigifactClient(
taxid="12345678",
username="FELUSER",
password="secret",
environment="test", # or "production"
)
# FACT CF — consumer final, IVA calculated automatically
result = client.invoice(
buyer="CF",
items=[{"description": "Consultoría", "qty": 1, "price": 100.00}]
)
print(result.auth_number)
# FACT to NIT — buyer name fetched from SAT automatically
result = client.invoice(
buyer="12345678",
items=[
{"description": "Laptop", "qty": 1, "price": 5000.00, "type": "Bien"},
{"description": "Soporte anual", "qty": 1, "price": 500.00},
]
)
# FACT to CUI buyer
result = client.invoice(
buyer={"taxid": "3730617490101", "type": "CUI", "name": "Juan Pérez"},
items=[{"description": "Producto", "qty": 2, "price": 50.00}]
)
# FCAM (Factura Cambiaria)
result = client.invoice(
buyer="12345678",
items=[{"description": "Servicio", "qty": 1, "price": 500.00}],
doc_type="FCAM",
payment_terms=[{"date": "2026-04-18", "amount": 500.00}]
)
# Credit note (NCRE)
result = client.credit_note(
buyer="12345678",
items=[{"description": "Devolución", "qty": 1, "price": 100.00}],
origin={
"auth_number": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"date": "2026-03-18",
"series": "XXXXXXXX",
"number": "123456",
},
reason="Producto defectuoso"
)
# Debit note (NDEB)
result = client.debit_note(
buyer="12345678",
items=[{"description": "Cargo adicional", "qty": 1, "price": 50.00}],
origin={...},
reason="Cargo por entrega express"
)
# Cancel a DTE
result = client.cancel(
auth_number="XXXXXXXX-...",
receiver_id="CF",
issue_datetime="2026-03-18 21:40:14",
reason="Error en monto"
)
# Total credit note
result = client.credit_note_total(
auth_number="XXXXXXXX-...",
issue_datetime="2026-03-18 21:40:14",
reason="Nota de crédito total"
)
# NIT lookup
info = client.lookup_nit("12345678")
print(info["name"])
# Retrieve DTE
doc = client.get_dte("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
Document types
| Type | Description | IVA |
|---|---|---|
FACT |
Standard invoice | Yes |
FCAM |
Factura Cambiaria (installments) | Yes |
NDEB |
Debit note | Yes |
NCRE |
Credit note | Yes |
NABN |
Nota de Abono | No |
FESP |
Factura Especial | Yes |
RDON |
Recibo por Donación | No |
FPEQ |
Factura Pequeño Contribuyente | No |
RECI |
Recibo universitario | No |
CCA |
Cobro por Cuenta Ajena | Yes |
IVA calculation
Prices are IVA-inclusive (what the customer pays):
line_total = qty × price
taxable_amount = line_total / 1.12
iva_amount = line_total − taxable_amount
All money values are formatted as strings with 6 decimal places.
Item dict keys
{
"description": str, # required
"price": float | Decimal, # required — unit price, IVA-inclusive
"qty": float | Decimal, # optional, default 1
"type": str, # optional: "Servicio" (default) | "Bien"
"unit_of_measure": str, # optional, default "UNI"
"discount": float | None, # optional — line discount amount
}
Running tests
# Unit tests (no credentials needed)
python -m pytest tests/ -v
# Integration tests
export DIGIFACT_TAXID=12345678
export DIGIFACT_USERNAME=FELUSER
export DIGIFACT_PASSWORD=your_password
python -m pytest tests/ -v
Environment variables
| Variable | Description |
|---|---|
DIGIFACT_TAXID |
Fiscal ID (e.g. 12345678) |
DIGIFACT_USERNAME |
Username (e.g. FELUSER) |
DIGIFACT_PASSWORD |
Account password |
Error handling
from digifact_sdk import (
DigifactError, # base
DigifactAuthError, # auth failure
DigifactApiError, # HTTP / API error
DigifactValidationError, # SAT rejection
DigifactNitNotFoundError, # NIT not found
)
try:
result = client.invoice("CF", [...])
except DigifactValidationError as exc:
print(f"SAT rejected: {exc}")
print(f"Code: {exc.code}")
print(f"Raw: {exc.raw}")
except DigifactError as exc:
print(f"SDK error: {exc}")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file digifact_sdk-2.0.2.tar.gz.
File metadata
- Download URL: digifact_sdk-2.0.2.tar.gz
- Upload date:
- Size: 19.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
275a158c46a4aca8d4e27d063e215d0fe6d3754bc27f7def3aeed0db36025d34
|
|
| MD5 |
bbbd5cd04249f859943c2fb28ebff42d
|
|
| BLAKE2b-256 |
1124be46336e6ae2f498a9a1eaaba17a4ecb5becbe1b5f780ee0ccba581a4952
|
Provenance
The following attestation bundles were made for digifact_sdk-2.0.2.tar.gz:
Publisher:
publish.yml on aalonzolu/digifact
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
digifact_sdk-2.0.2.tar.gz -
Subject digest:
275a158c46a4aca8d4e27d063e215d0fe6d3754bc27f7def3aeed0db36025d34 - Sigstore transparency entry: 1187364738
- Sigstore integration time:
-
Permalink:
aalonzolu/digifact@7253996134cb5f524af424666618de44f61b94e0 -
Branch / Tag:
refs/tags/v2.0.2 - Owner: https://github.com/aalonzolu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7253996134cb5f524af424666618de44f61b94e0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file digifact_sdk-2.0.2-py3-none-any.whl.
File metadata
- Download URL: digifact_sdk-2.0.2-py3-none-any.whl
- Upload date:
- Size: 16.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2128cb359a0fd22972e6333edfcb33907f22c94dd4042dd4992099fd76aefdd3
|
|
| MD5 |
e8513a7c577998744c0cea89284884e6
|
|
| BLAKE2b-256 |
4025ecbd226357d31537368c2b991b2ab60bd5c7dfc77724bcaae4619e15b92f
|
Provenance
The following attestation bundles were made for digifact_sdk-2.0.2-py3-none-any.whl:
Publisher:
publish.yml on aalonzolu/digifact
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
digifact_sdk-2.0.2-py3-none-any.whl -
Subject digest:
2128cb359a0fd22972e6333edfcb33907f22c94dd4042dd4992099fd76aefdd3 - Sigstore transparency entry: 1187364744
- Sigstore integration time:
-
Permalink:
aalonzolu/digifact@7253996134cb5f524af424666618de44f61b94e0 -
Branch / Tag:
refs/tags/v2.0.2 - Owner: https://github.com/aalonzolu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7253996134cb5f524af424666618de44f61b94e0 -
Trigger Event:
push
-
Statement type: