Official async Python SDK and CLI for BrokenX YouTube API
Project description
BROKENXAPI Documentation
BROKENXAPI is an async-first Python SDK that allows developers to access BrokenX YouTube services securely using an API key.
[!CAUTION] IMPORTANT DISCLAIMER
This project is designed for Educational Purposes Only. Usage of this software to download copyrighted content (Music/Videos) without permission may violate YouTube's Terms of Service and local copyright laws.
The developer (MR BROKEN) assumes NO responsibility for any misuse or legal consequences resulting from the use of this tool. Use it at your own risk.
Features
- Async / non-blocking
- Secure header-based authentication
- Clean SDK (no backend exposure)
- Telegram-powered media delivery
Requirements
- Python 3.8 or higher
- Valid BrokenX API key Get it from Here
- Internet access
Install with pip:
pip install BROKENXAPI
Quick Start
Recommended: set your API key as an environment variable for local development.
Linux / macOS:
export API_KEY="BROKENXAPI-XXXX"
Windows (cmd):
set API_KEY=BROKENXAPI-XXXX
Basic usage (using env var):
import os
import asyncio
from brokenxapi import BrokenXAPI
API_KEY = os.getenv("API_KEY") # recommended
async def main():
async with BrokenXAPI(api_key=API_KEY) as api:
result = await api.search("Arijit Singh")
print(result)
asyncio.run(main())
Or pass API key directly (less secure):
async with BrokenXAPI(api_key="BROKENXAPI-XXXX") as api:
result = await api.search("No Copyright sounds", video=False)
Authentication
BROKENXAPI uses header-based authentication. The SDK sets the Authorization header for you when you pass api_key to the constructor.
Header format (used internally by the SDK):
Authorization: Bearer YOUR_API_KEY
Do not commit or share your API key in public repositories.
Context-manager usage:
async with BrokenXAPI(api_key="...") as api:
...
search(query: str, video: bool = False, limit: int = 20)
Search for YouTube content.
-
Parameters:
- query (str): search keyword
- video (bool): False = audio (default), True = video
- limit (int): number of results to request (default 20)
-
Returns: dict — a JSON-compatible dictionary including keys such as:
- title
- video_id
- duration
- thumbnail
Example:
result = await api.search("no copyright sounds", video=False)
video_id = result["video_id"]
download(video_id: str, media: str = "audio")
Download audio or video via BrokenX backend.
-
Parameters:
- video_id (str): YouTube video id
- media (str): "audio" (default) or "video"
-
Returns: dict — download metadata. Example keys:
- telegram_url
Example:
audio = await api.download(video_id, media="audio")
print(audio["telegram_url"])
Notes:
- The SDK converts boolean query parameters to strings before sending (e.g. True -> "true").
- All network requests raise on non-2xx responses via aiohttp.
Error Handling
All SDK errors inherit from BrokenXAPIError.
Example:
from brokenxapi.exceptions import BrokenXAPIError
try:
await api.download("invalid_id")
except BrokenXAPIError as e:
print("Error:", e)
CLI
The package provides a brokenx CLI. Example usage:
- Save API key:
brokenx auth BROKENXAPI-XXXX
- Search:
brokenx search "no copyright sounds"
- Download (audio):
brokenx download VIDEO_ID
- Download (video):
brokenx download VIDEO_ID -v
Running tests
Set the YTKEY env var before running tests that hit the real backend:
export API_KEY="BROKENXAPI-XXXX"
pytest -q
Tests that require a live API key are skipped automatically if API_KEY is not set.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file brokenxapi-2.0.7-py3-none-any.whl.
File metadata
- Download URL: brokenxapi-2.0.7-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
406938d5491fff5f674030012733ba5a4fb61760bf1c1ab3a2234a77ad8dc22d
|
|
| MD5 |
e77bd188e3a08228fa0a8f13e5ff0863
|
|
| BLAKE2b-256 |
470305215bb1cbccc3b3dfa10f075cfcc7c124c86bcbb345f1869e2836f4ba0a
|