Python SDK setup
Guide
Keep your API key on your server. See SDK timeouts and recovery.
Python
Section titled “Python”Requires Python 3.9+. Install the source distribution in a virtual environment:
python3 -m venv .venv. .venv/bin/activatepython -m pip install https://docs.omnapi.com/sdk/omnapi-python-0.3.0.tar.gzimport osfrom omnapi import OmnapiClient, OmnapiError
client = OmnapiClient(os.environ["OMNAPI_KEY"], timeout=30)try: # Resume an accepted job using its saved ID; this does not create new work. task = client.wait_for_task(os.environ["OMNAPI_TASK_ID"], timeout_sec=1800) if task["status"] != "COMPLETED": raise RuntimeError(f"Task ended: {task['status']}") for resource in task.get("resources", []): if resource.get("type") in ("MUSIC", "AUDIO", "VIDEO", "IMAGE"): print(resource.get("url"))except OmnapiError as error: print(error.status_code, error.code, error.request_id) raiseKeep media URLs and error details in private application logs. For creation and persisted receipts, start with the Python song program.