No Facta library required
Call the public Supabase function URL directly. Keep API keys and signing keys on your server.
Prerequisite
Python 3 + urllib.request
Example
"""Minimal Facta API call. Keep the idempotency key when retrying."""
import os
from urllib.request import Request, urlopen
import json
payload = {"tipoDte": "01", "items": [{"descripcion": "Servicio", "cantidad": 1, "precioUni": 10.0}]}
base_url = os.environ["FACTA_API_BASE_URL"].rstrip("/")
request = Request(f"{base_url}/v1/dte", data=json.dumps(payload).encode(), method="POST", headers={"Content-Type": "application/json", "X-Facta-Key": os.environ["FACTA_API_KEY"], "X-Facta-Sign-Key": os.environ["FACTA_SIGN_KEY"], "Idempotency-Key": "order-123"})
with urlopen(request, timeout=60) as response:
print(json.load(response))
See the HTTP reference for headers, responses and recovery rules.