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.
❤️ Support the Project
If you like this project, you can support development using crypto:
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)
Backend base URL notes:
- You do not need to pass
base_urlfor normal use. - If needed (self-hosted/proxy), set
BROKENXAPI_BASE_URLor passbase_url=....
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
- MADE WITH ❤🩹 By MR BROKEN
DROP YOUR ISSUES
- At Here ISSUE
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.9-py3-none-any.whl.
File metadata
- Download URL: brokenxapi-2.0.9-py3-none-any.whl
- Upload date:
- Size: 8.5 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 |
d52703517b012b07ed19c5cf46eb4b0e94d6cc291a8e8a13c3bb9c80c21e5c7d
|
|
| MD5 |
d138cf44aa1a299874eb3f4ec8a13f6f
|
|
| BLAKE2b-256 |
006f86316319bbab8960d290cfdf253d317718038af75e9dcc136741bd83ba99
|