This release is a pre-release and may not be stable for production use.
ecuafact (Python)
Cliente oficial en Python del API publico de facturacion electronica Ecuafact (contrato v1). Cubre autenticacion, idempotencia, reintentos y firma de webhooks. Requiere Python 3.9+.
Instalacion
pip install ecuafact
Uso
import os
from ecuafact import ComprobanteRequest, EcuafactClient, EcuafactClientOptions, InfoTributaria
client = EcuafactClient(EcuafactClientOptions(
base_address="https://staging-api.mynexusapi.com/", # sandbox; produccion: https://api.mynexusapi.com/
api_key=os.environ["ECUAFACT_API_KEY"],
identificacion="1790012345001", # solo integraciones de un RUC
))
resultado = client.emitir(ComprobanteRequest(
origen_referencia="MiERP",
referencia_externa="FACTURA-2026-0001",
info_tributaria=InfoTributaria(
ruc="1790012345001", cod_doc="01", estab="002", pto_emi="001", secuencial="000000123"
),
# info=..., detalles=...
))
print(resultado.admission.id_operacion, resultado.admission.codigo)
Multi-RUC
ruc = client.para("1790099987001")
pagina = ruc.listar_emitidos()
Idempotencia
idempotency_key es opcional: si no se envia, el SDK la genera, la reutiliza en los reintentos y la
devuelve en resultado.idempotency_key (y en el error, como EcuafactApiException.idempotency_key).
Al reintentar a nivel de aplicacion reutiliza la clave devuelta. La correlacion de la respuesta
queda en resultado.correlation_id (o EcuafactApiException.id_seguimiento en error).
Los fallos transitorios (408/425/429/5xx) se reintentan con la misma clave respetando Retry-After;
el resto de los 4xx no.
Opciones
| Opcion | Default | Descripcion |
|---|---|---|
base_address |
— | Direccion base del API (obligatoria) |
api_key |
— | Credencial X-Api-Key (obligatoria) |
identificacion |
None |
RUC por defecto (opcional) |
timeout |
100.0 |
Tiempo maximo por intento (segundos) |
user_agent |
Ecuafact.Sdk/1.0 |
User-Agent |
retry_transient_failures |
True |
Reintenta 408/425/429/5xx |
max_attempts |
3 |
Intentos por solicitud |
respect_retry_after |
True |
Respeta Retry-After en 429/503 |
max_retry_delay_ms |
60000 |
Espera maxima entre reintentos |
Errores
Los errores del API se lanzan como EcuafactApiException (codigo, mensaje, estado_http,
id_seguimiento, errores, idempotency_key). Los errores locales de configuracion o transporte son
EcuafactSdkException.
Webhooks
from ecuafact import verify
valido = verify(secreto, cabecera, cuerpo_crudo, tolerance_seconds=300)
Documentacion
Licencia
MIT.
Metadata
Release files for ecuafact 1.0.0b1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ecuafact-1.0.0b1.tar.gz | 18.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ecuafact-1.0.0b1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.3 kB
Release files / ecuafact-1.0.0b1.tar.gz
| Download URL | ecuafact-1.0.0b1.tar.gz |
|---|---|
| Size | 18.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
599301f59af63b4ca3b1fb7aebe051cc9f729b1e3e622ab435a4e0ada5a230bc
|
|
BLAKE2b-256 checksum How to use checksums |
47aaa917dd4143b42dc70d4e19786cbf0a8f6eedc0f88172f3625354968bf231
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / ecuafact-1.0.0b1-py3-none-any.whl
| Download URL | ecuafact-1.0.0b1-py3-none-any.whl |
|---|---|
| Size | 15.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4896215ad216006d623dea30925a595c7b80ee00ad98ccaf849ee6883f880cef
|
|
BLAKE2b-256 checksum How to use checksums |
f89060e916ba4830045120d0692cdb1b4530aa607b99124c67faf53652182647
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|