Metadata-Version: 2.4
Name: hadidy-audio
Version: 0.1.0
Summary: Official Python SDK for the Hadidy Audio Transcoding API
Project-URL: Homepage, https://hadidy.com/docs/sdks/python
Project-URL: Repository, https://github.com/hadidybase/hadidy-audio-python
Author-email: Hadidy Audio <sdk@hadidy.com>
License: MIT
Keywords: audio,hadidy,sdk,transcoding
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Requires-Dist: httpx<1.0,>=0.27
Requires-Dist: pydantic<3.0,>=2.0
Provides-Extra: dev
Requires-Dist: mypy>=1.9; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: respx>=0.21; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Description-Content-Type: text/markdown

# hadidy-audio

Official Python SDK for the [Hadidy Audio](https://hadidy.com) Transcoding API. Supports Python 3.10+ with both synchronous and asynchronous clients.

## Installation

```bash
pip install hadidy-audio
```

## Quick Start — Synchronous

```python
from hadidy import AudioClient

client = AudioClient(api_key="had_live_...")

with open("podcast.wav", "rb") as f:
    job = client.jobs.create(f, output_format="mp3", bitrate="192k")

completed = client.jobs.wait_for_completion(job["id"], timeout=300)
print(completed["output_url"])
```

## Quick Start — Async

```python
import asyncio
from hadidy import AsyncAudioClient

async def main():
    async with AsyncAudioClient(api_key="had_live_...") as client:
        async for job in client.jobs.list_all(status="completed"):
            print(f"{job['file_name']} → {job['output_url']}")

asyncio.run(main())
```

## Webhook Verification — FastAPI

```python
from hadidy import WebhookVerifier
from fastapi import FastAPI, Request, HTTPException, Depends
import os

app = FastAPI()
verifier = WebhookVerifier(secret=os.environ["HADIDY_WEBHOOK_SECRET"])

@app.post("/hooks/hadidy")
async def webhook(request: Request, _=Depends(verifier.fastapi_dependency())):
    event = await request.json()
    print(event["type"], event["data"]["job_id"])
    return {"ok": True}
```

## API Coverage

| Resource | Sync | Async |
|---|---|---|
| `client.jobs` | `list()`, `list_all()`, `get()`, `create()`, `delete()`, `get_output()`, `wait_for_completion()` | ✓ |
| `client.presets` | `list()`, `list_all()`, `get()`, `create()`, `update()`, `delete()` | ✓ |
| `client.codecs` | `list_codecs()`, `list_formats()`, `capabilities()` | ✓ |
| `client.analysis` | `analyze(file)` | ✓ |
| `client.audio` | `waveform_data()`, `silence()`, `get_metadata()`, `update_metadata()`, `concat()` | ✓ |
| `client.webhooks` | `list()`, `get()`, `create()`, `update()`, `delete()`, `deliveries()`, `test()` | ✓ |
| `client.billing` | `balance()`, `history()`, `service_costs()` | ✓ |
| `client.folders` | `list()`, `get()`, `breadcrumb()`, `create()`, `update()`, `delete()`, `move_files()` | ✓ |
| `client.sharing` | `list()`, `get()`, `create()`, `update()`, `delete()`, `get_public_info()`, `verify_passcode()` | ✓ |
| `client.live` | Full session management, sources, recordings | ✓ |

## Error Handling

```python
from hadidy import AudioClient, RateLimitError, NotFoundError, HadidyError

client = AudioClient(api_key="had_live_...")

try:
    job = client.jobs.get("nonexistent-id")
except NotFoundError:
    print("Job not found")
except RateLimitError as e:
    print(f"Rate limited, retry after {e.retry_after}s")
except HadidyError as e:
    print(f"API error {e.status}: {e}")
```

## Configuration

```python
client = AudioClient(
    api_key="had_live_...",
    base_url="https://api.hadidy.com",  # default
    timeout=30.0,                        # default: 30s
    max_retries=2,                       # default: 2
)
```

## License

MIT
