Skip to main content

Official Python SDK for the Hadidy Audio Transcoding API

Project description

hadidy-audio

Official Python SDK for the Hadidy Audio Transcoding API. Supports Python 3.10+ with both synchronous and asynchronous clients.

Installation

pip install hadidy-audio

Quick Start — Synchronous

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

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

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

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hadidy_audio-0.1.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hadidy_audio-0.1.0-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file hadidy_audio-0.1.0.tar.gz.

File metadata

  • Download URL: hadidy_audio-0.1.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for hadidy_audio-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e2c580cc415b565d943b1b01bd40c612611a8dc08dc58fe314b71e9c99c9b0d3
MD5 e5c57f62b7259e565965827e5cd22026
BLAKE2b-256 78ac78870c11fa113be737f033e0960ac17b557202edfe0534f80bb35c8bf3dc

See more details on using hashes here.

File details

Details for the file hadidy_audio-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hadidy_audio-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for hadidy_audio-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eb052d6015e07925a7c6a1ba2f9e1921fccf39534194a882d98924f261617468
MD5 36080f8e4939dbd980d783797f77e613
BLAKE2b-256 02e225d3792267c962e564a713952beb01d621ca6b9ffd8ad23a4e3d77dbc6df

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page