Metadata-Version: 2.4
Name: directsaz
Version: 1.0.1
Summary: Directsaz Developer API SDK for Python (Django, FastAPI, Flask, plain)
Author: Directsaz
License: MIT
Keywords: directsaz,instagram,webhook,sdk
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Framework :: Django
Classifier: Framework :: FastAPI
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.27
Provides-Extra: fastapi
Requires-Dist: fastapi>=0.110; extra == "fastapi"
Provides-Extra: django
Requires-Dist: django>=4.2; extra == "django"

# Directsaz Python SDK

Works with **FastAPI**, **Django**, Flask, or plain scripts. Uses `httpx`.

## Install

```bash
pip install ./new-go-apps/sdk/python
# or editable:
pip install -e ./new-go-apps/sdk/python
# with FastAPI extras:
pip install -e "./new-go-apps/sdk/python[fastapi]"
```

## Send API

```python
from directsaz import Client

with Client(api_key="ds_live_…") as ds:
    ds.send_dm(recipient_id, "Hello")
    ds.send_image(recipient_id, "https://cdn.example.com/a.jpg", buttons=[
        {"title": "Open", "url": "https://example.com"},
    ])
    ds.send_carousel(recipient_id, cards)
    ds.private_reply(comment_id, "Thanks!")
    ds.comment_reply(comment_id, "Public reply")
    ds.like(recipient_id, message_id)
    ds.list_posts(limit=30)
    ds.follow_status(user_id)
```

## FastAPI webhook

```python
import os
from fastapi import FastAPI
from directsaz import Client
from directsaz.fastapi_app import webhook_router

app = FastAPI()
ds = Client(api_key=os.environ["DIRECTSAZ_API_KEY"])

async def on_events(events, request):
    for event in events:
        if event.get("type") == "dm":
            rid = (event.get("actions") or {}).get("dm", {}).get("recipient_id")
            if rid:
                ds.send_dm(rid, "Got it")

app.include_router(
    webhook_router(os.environ["DIRECTSAZ_WEBHOOK_TOKEN"], on_events=on_events)
)
```

## Django webhook

```python
# urls.py
from directsaz.django_app import make_webhook_view

urlpatterns = [
    path("hooks/directsaz", make_webhook_view(on_events=my_handler)),
]
```

Set `DIRECTSAZ_WEBHOOK_TOKEN` in Django settings.
