Frameworks
Django — Intégration Scell.io
Pas de SDK Python officiel — appel HTTP direct via requests
Scell.io ne publie PAS de SDK Python officiel (seuls TypeScript et PHP sont supportés). En Django, intégrer via la lib `requests` en appelant directement `POST /api/v1/invoices` avec header `X-API-Key`. Encapsuler dans un service Python (`services/scell.py`) injecté dans les vues. Pour async, utiliser `httpx` ou Celery pour les jobs.
À retenir
- Pas de SDK Python officiel — `requests` ou `httpx`
- Header obligatoire : `X-API-Key: sk_live_xxx`
- Endpoint : `POST https://api.scell.io/api/v1/invoices`
- Stocker `SCELL_API_KEY` dans `settings.py` via env var
- Pour async : Celery task ou Django 5.0 async views
Exemple de code
import requests
from django.conf import settings
def create_invoice(buyer_name: str, amount: float) -> dict:
payload = {
'format': 'factur-x',
'buyer': {'name': buyer_name, 'is_individual': True},
'lines': [{'description': 'Service', 'quantity': 1, 'unit_price': amount, 'vat_rate': 20.0}],
}
r = requests.post(
'https://api.scell.io/api/v1/invoices',
json=payload,
headers={'X-API-Key': settings.SCELL_API_KEY},
timeout=30,
)
r.raise_for_status()
return r.json()