Minimales Beispiel (Python)
import httpx
API_KEY = "sk_live_..."
BASE = "https://subli.ch"
# 1. Job starten
resp = httpx.post(f"{BASE}/api/v1/transcribe",
headers={"Authorization": f"Bearer {API_KEY}"},
json={"url": "https://example.com/podcast.mp3"})
job_id = resp.json()["job_id"]
# 2. Auf Fertigstellung warten
import time
while True:
status = httpx.get(f"{BASE}/api/v1/job/{job_id}",
headers={"Authorization": f"Bearer {API_KEY}"}).json()
if status["status"] == "done":
break
time.sleep(5)
# 3. SRT herunterladen
srt = httpx.get(f"{BASE}/api/v1/result/{job_id}",
headers={"Authorization": f"Bearer {API_KEY}"}).text
print(srt)
Mit Webhook (empfohlen)
resp = httpx.post(f"{BASE}/api/v1/transcribe",
headers={"Authorization": f"Bearer {API_KEY}"},
json={
"url": "https://example.com/podcast.mp3",
"webhook_url": "https://dein-server.com/callback"
})
# SUBLI ruft dich auf, sobald der Job fertig ist.
Wenn du webhook_url mitgibst, sendet SUBLI bei Job-Abschluss einen POST mit diesem Payload:
{
"event": "transcription.done",
"job_id": "…",
"status": "done",
"result_url": "https://subli.ch/api/v1/result/{job_id}",
"srt_url": "https://subli.ch/api/v1/result/{job_id}?format=srt",
"json_url": "https://subli.ch/api/v1/result/{job_id}?format=json"
}
Signatur verifizieren
Jeder Webhook-Request enthält den Header X-Subli-Signature — ein HMAC-SHA256 des JSON-Body, signiert mit deinem Webhook Secret (sichtbar in der Key-Liste oben).
import hmac, hashlib, json
def verify(body_bytes, signature, secret):
expected = hmac.new(
secret.encode(), body_bytes, hashlib.sha256
).hexdigest()
return hmac.compare_digest(expected, signature)