Frameworks
Flask — Scell.io integration
Sync via requests + Flask extension
Scell.io does NOT publish an official Python SDK. For Flask, use `requests.Session()` (sync) initialised in `app.config` and accessible via `current_app`. For heavy workloads, offload to Celery. No magic: direct HTTP call to `https://api.scell.io/api/v1/invoices` with `X-API-Key`.
Key facts
- Shared `requests.Session()` in `app.config`
- No Python SDK — direct HTTP call
- For async/queue: Celery + Redis broker
- `SCELL_API_KEY` via `os.environ` (never in code)
- Compatible with Flask 2.x and 3.x
Code example
import os, requests
from flask import Flask, request, jsonify, current_app
app = Flask(__name__)
app.config['SCELL'] = requests.Session()
app.config['SCELL'].headers.update({'X-API-Key': os.environ['SCELL_API_KEY']})
@app.post('/invoice')
def create_invoice():
body = request.get_json()
r = current_app.config['SCELL'].post(
'https://api.scell.io/api/v1/invoices',
json={'format': 'factur-x', 'lines': [{'description': body['label'], 'quantity': 1, 'unit_price': body['amount'], 'vat_rate': 20.0}]},
timeout=30,
)
return jsonify(r.json()), r.status_code