intifact-sdk (Python)
SDK Python para la API de Facturación Electrónica SUNAT de Intifact (Perú),
generado con OpenAPI Generator desde el spec
que la API expone en /docs/json. Facturas, boletas, notas de crédito/débito,
guías de remisión (remitente y transportista), resúmenes diarios y
comunicaciones de baja.
Requisitos
Python 3.10+
Instalación
pip install intifact
Autenticación
La API no está modelada con un securityScheme de OpenAPI (el chequeo de API
key vive en un plugin de Fastify), así que el header se agrega a mano — el
cliente lo manda en cada request a partir de ahí:
import intifact_sdk
from intifact_sdk import ApiClient, Configuration
config = Configuration(host="https://api-facturacion.intifact.com")
client = ApiClient(config)
client.set_default_header("Authorization", f"Bearer {os.environ['FACTURACION_API_KEY']}")
Uso básico — enviar una factura
import os
from intifact_sdk import ApiClient, Configuration, ApiException
from intifact_sdk.api.invoice_api import InvoiceApi
from intifact_sdk.models.api_v1_invoice_send_post_request import ApiV1InvoiceSendPostRequest
from intifact_sdk.models.api_v1_invoice_send_post_request_detalle_inner import (
ApiV1InvoiceSendPostRequestDetalleInner,
)
config = Configuration(host="https://api-facturacion.intifact.com")
with ApiClient(config) as client:
client.set_default_header("Authorization", f"Bearer {os.environ['FACTURACION_API_KEY']}")
invoice_api = InvoiceApi(client)
item = ApiV1InvoiceSendPostRequestDetalleInner(
unidad="NIU",
cantidad=2,
cod_producto="PROD001",
descripcion="Laptop HP 15",
monto_valor_unitario=2500.00,
monto_base_igv=5000.00,
porcentaje_igv=18,
igv=900.00,
tip_afe_igv="10",
total_impuestos=900.00,
monto_precio_unitario=2950.00,
monto_valor_venta=5000.00,
# Código de Producto SUNAT (UNSPSC) — SUNAT lo exige desde 2027-01-01
# para determinados bienes (error 3496 si falta o es inválido).
cod_prod_sunat="43211508",
)
body = ApiV1InvoiceSendPostRequest(
empresa_ruc="20553510661",
tipo_doc="01",
serie="F001",
correlativo="100",
tipo_moneda="PEN",
fecha_emision="2026-01-15",
tipo_operacion="0101",
cliente_tipo_doc="6",
cliente_num_doc="20000000001",
cliente_razon_social="EMPRESA CLIENTE SAC",
detalle=[item],
monto_oper_gravadas=5000.00,
monto_oper_exoneradas=0,
monto_igv=900.00,
total_impuestos=900.00,
valor_venta=5000.00,
sub_total=5900.00,
monto_imp_venta=5900.00,
forma_pago=[{"tipo": "Contado", "monto": 5900.00, "fechaPago": "2026-01-15"}],
leyendas=[{"legendCode": "1000", "legendValue": "CINCO MIL NOVECIENTOS CON 00/100 SOLES"}],
)
try:
resp = invoice_api.api_v1_invoice_send_post(body)
# 202 — el documento queda ENCOLADO, SUNAT lo procesa en background
print("Encolado:", resp.data.id)
except ApiException as e:
# El body real del error (400/401/409/...) viene en e.body
print(f"Error {e.status}: {e.body}")
Notas:
- Los campos usan
snake_caseen Python (cod_producto) aunque el JSON que viaja por HTTP sigue siendocamelCase(codProducto) — Pydantic hace la conversión conaliasautomáticamente. - Pydantic valida los modelos al construirlos, antes de cualquier llamada
de red: si falta un campo requerido (ej.
forma_pago,leyendas), obtienes unValidationErrorlocal en vez de esperar un 400 del servidor. Es una ventaja real del SDK Python frente a mandar un dict suelto.
Manejo de errores
Toda respuesta fuera de 2xx llega como ApiException (no como excepción
genérica de red): e.status trae el código HTTP y e.body el JSON crudo
{ success: false, message, errors? } que devuelve la API.
try:
invoice_api.api_v1_invoice_send_post(body)
except ApiException as e:
if e.status == 409:
# Comprobante ya en proceso — NO reintentar con otro correlativo,
# esperar el resultado. Ver /documents/{id} para el estado final.
pass
APIs disponibles
| Clase | Para qué |
|---|---|
InvoiceApi |
Facturas/boletas: enviar, PDF, XML, CDR |
NoteApi |
Notas de crédito/débito |
DespatchApi |
Guías de remisión (remitente y transportista) |
SummaryApi |
Resumen diario y comunicación de baja |
DocumentsApi |
Listar/consultar documentos, reintentar fallidos |
QueuesApi |
Estado de las colas BullMQ |
CompanyApi / BranchesApi |
Empresas y establecimientos (solo lectura) |
WebhooksApi |
Suscripciones y entregas de webhooks |
PlansApi |
Planes y consumo (quota) |
PublicApi |
Consulta pública de comprobantes (sin auth) |
AuthApi |
Autenticación |
SystemApi |
/health, catálogos SUNAT |
Regenerar desde la API
El proyecto se generó con OpenAPI Generator
(python) contra https://api-facturacion.intifact.com/docs/json. Para
regenerar tras un cambio de la API:
npx @openapitools/openapi-generator-cli generate \
-i https://api-facturacion.intifact.com/docs/json \
-g python --package-name intifact_sdk \
-o .
Nota sobre los nombres de métodos
Las rutas de la API no declaran operationId explícito en su schema de
Fastify, así que el generador deriva nombres desde el método+path
(api_v1_invoice_send_post en vez de algo como send_invoice). Si la API le
agrega operationId a sus rutas, una regeneración futura produciría nombres
más limpios sin romper compatibilidad de comportamiento.
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 intifact-2.1.0.tar.gz.
File metadata
- Download URL: intifact-2.1.0.tar.gz
- Upload date:
- Size: 169.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb2dcabf1a054a928b893091ab85e682653db0100dcf7feb0a91b0f1ec5f155a
|
|
| MD5 |
d3f2ac03e2563c82e805dd34250f77bf
|
|
| BLAKE2b-256 |
daac424597dc4f068a7b08c0f889c6727ca210a8dad11fc60cbe18a617e8d0e8
|
Provenance
The following attestation bundles were made for intifact-2.1.0.tar.gz:
Publisher:
publish-pypi.yml on RogerAC123/api-facturacion-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
intifact-2.1.0.tar.gz -
Subject digest:
cb2dcabf1a054a928b893091ab85e682653db0100dcf7feb0a91b0f1ec5f155a - Sigstore transparency entry: 2745021623
- Sigstore integration time:
-
Permalink:
RogerAC123/api-facturacion-sdk-python@8e711098391bf24dd63592c69e49b6314190c8cd -
Branch / Tag:
refs/tags/v2.1.0 - Owner: https://github.com/RogerAC123
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@8e711098391bf24dd63592c69e49b6314190c8cd -
Trigger Event:
push
-
Statement type:
File details
Details for the file intifact-2.1.0-py3-none-any.whl.
File metadata
- Download URL: intifact-2.1.0-py3-none-any.whl
- Upload date:
- Size: 363.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
965a269ec6955fee2cb8b527cd8805cbd355223a8ce4c96597cc8b72dc7c3d8e
|
|
| MD5 |
0ec1119a73d530b044a12e379c042a2e
|
|
| BLAKE2b-256 |
2e9bc52d1d895df02a87f02265fe987072f3fa051a9daea2502b44ab2e1e94e6
|
Provenance
The following attestation bundles were made for intifact-2.1.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on RogerAC123/api-facturacion-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
intifact-2.1.0-py3-none-any.whl -
Subject digest:
965a269ec6955fee2cb8b527cd8805cbd355223a8ce4c96597cc8b72dc7c3d8e - Sigstore transparency entry: 2745022324
- Sigstore integration time:
-
Permalink:
RogerAC123/api-facturacion-sdk-python@8e711098391bf24dd63592c69e49b6314190c8cd -
Branch / Tag:
refs/tags/v2.1.0 - Owner: https://github.com/RogerAC123
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@8e711098391bf24dd63592c69e49b6314190c8cd -
Trigger Event:
push
-
Statement type: