DarhimLabs API
Python SDK
Oficjalny pakiet PyPI darhimlabs: sync client, async wrapper, pagination i webhook verification.
Python SDK
darhimlabs jest oficjalnym SDK dla Pythona 3.10+. Pakiet zawiera klienta sync, lekki async wrapper, retry/backoff, idempotency headers, iterator pagination i bezpieczna weryfikacje webhookow.
Instalacja
pip install darhimlabs
Pierwszy call
import os
from darhimlabs import DarhimLabs
client = DarhimLabs(api_key=os.environ["DARHIMLABS_API_KEY"])
page = client.inbox.conversations.list(status="open", limit=10)
for conversation in page.data:
print(conversation["id"])
Auto-pagination
for conversation in client.inbox.conversations.iterate(status="open"):
print(conversation["id"])
Send message z idempotency
message = client.inbox.conversations.send_message(
conversation_id="conv_123",
content="Czesc! Czym moge pomoc?",
idempotency_key="message_123"
)
Async wrapper
import asyncio
from darhimlabs import AsyncDarhimLabs
async def main():
async with AsyncDarhimLabs(api_key=os.environ["DARHIMLABS_API_KEY"]) as client:
page = await client.run_sync(client.inbox.conversations.list, status="open")
print(page.data)
asyncio.run(main())
Webhook verification
from darhimlabs import DarhimLabs
client = DarhimLabs(api_key=os.environ["DARHIMLABS_API_KEY"])
event = client.webhooks.verify_signature(
payload=raw_body,
signature_header=request.headers["DL-Status-Signature"],
secret=os.environ["DARHIMLABS_WEBHOOK_SECRET"]
)
Generowane typy
darhimlabs/types.py jest generowany z OpenAPI:
npm run build:openapi
npm run sdk:types
Plik zawiera OPENAPI_VERSION, OPERATION_IDS, SCHEMA_NAMES i OPERATIONS.
Release
Tag sdk-python-v0.1.0 uruchamia workflow publikacji: build wheel/sdist i upload do PyPI przez TWINE_PASSWORD=${PYPI_TOKEN}.