Démarrage rapide
Quickstart : créer une facture en Python
Pas de SDK officiel — utiliser requests (BYO client)
Il n'existe pas de SDK Python officiel pour Scell.io. L'API étant 100% REST + JSON, n'importe quel client HTTP fait l'affaire : `requests` (synchrone), `httpx` (async/sync), `aiohttp` (async). Le pattern est : header `X-API-Key`, body JSON snake_case, retries manuels recommandés (urllib3 Retry adapter). Compatible avec FastAPI, Django, Flask, scripts CLI, et notebooks Jupyter. Pour Pydantic, dériver vos modèles depuis `docs/api/openapi.json` (publié sur api.scell.io).
À retenir
- Prérequis : Python 3.10+, `pip install requests`
- Pas de SDK officiel : BYO client (requests, httpx, aiohttp)
- Variable d'env : `os.environ['SCELL_API_KEY']`
- HTTP : `requests` recommandé pour la simplicité
- Output attendu : dict JSON avec `id`, `status`, `pdf_url`
- Codes erreur : `response.raise_for_status()` + try/except `requests.HTTPError`
Exemple de code
import os
import uuid
import requests
API = "https://api.scell.io/api/v1"
HEADERS = {
"X-API-Key": os.environ["SCELL_API_KEY"],
"Content-Type": "application/json",
}
def call(path, body):
h = {**HEADERS, "Idempotency-Key": str(uuid.uuid4())}
r = requests.post(f"{API}{path}", headers=h, json=body, timeout=30)
r.raise_for_status()
return r.json()
seller = {
"siret": "12345678901234", "name": "Ma SAS", "vat_number": "FR12345678901",
"address": {"street": "1 rue Test", "city": "Paris", "postal_code": "75001", "country": "FR"},
}
# 1. Facture B2B
b2b = call("/invoices", {
"format": "factur-x", "profile": "EN16931", "currency": "EUR", "seller": seller,
"buyer": {
"siret": "98765432109876", "name": "Client SARL",
"address": {"street": "2 avenue Demo", "city": "Lyon", "postal_code": "69001", "country": "FR"},
},
"lines": [{"description": "Prestation conseil", "quantity": 1, "unit_price": 1000.0, "vat_rate": 20.0}],
})
print(f"B2B: {b2b['id']} ({b2b['status']})")
# 2. Facture B2C (particulier)
b2c = call("/invoices", {
"format": "factur-x", "profile": "EN16931", "currency": "EUR", "seller": seller,
"buyer": {
"buyer_is_individual": True, "name": "Jean Dupont", "email": "jean@example.com",
"address": {"street": "3 bd Client", "city": "Marseille", "postal_code": "13001", "country": "FR"},
},
"lines": [{"description": "Abonnement", "quantity": 1, "unit_price": 49.90, "vat_rate": 20.0}],
})
print(f"B2C: {b2c['id']} ({b2c['status']})")
# 3. Signature simple eIDAS EU-SES
sig = call("/signatures", {
"document_url": "https://example.com/contrat.pdf",
"signers": [{"name": "Jean Dupont", "email": "jean@example.com", "phone": "+33612345678"}],
"signature_options": {"signature_mode": "drawn", "timezone": "Europe/Paris"},
})
print(f"Signature: {sig['id']} -> {sig['signing_url']}")