BROKENXAPI 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,277 @@
1
+ Metadata-Version: 2.4
2
+ Name: BROKENXAPI
3
+ Version: 2.0.0
4
+ Summary: Official async Python SDK and CLI for BrokenX YouTube API
5
+ Author-email: Mr Broken <brokenxnetwork@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Mr Broken
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/BrokenXNetwork/BROKENXAPI
29
+ Project-URL: Repository, https://github.com/BrokenXNetwork/BROKENXAPI
30
+ Project-URL: Documentation, https://brokenxapi-docs.vercel.app
31
+ Project-URL: Issues, https://github.com/BrokenXNetwork/BROKENXAPI/issues
32
+ Keywords: brokenx,youtube,api,async,sdk,cli,aiohttp,telegram
33
+ Classifier: Development Status :: 5 - Production/Stable
34
+ Classifier: Intended Audience :: Developers
35
+ Classifier: Topic :: Software Development :: Libraries
36
+ Classifier: Topic :: Multimedia :: Video
37
+ Classifier: License :: OSI Approved :: MIT License
38
+ Classifier: Operating System :: OS Independent
39
+ Classifier: Programming Language :: Python :: 3
40
+ Classifier: Programming Language :: Python :: 3 :: Only
41
+ Classifier: Programming Language :: Python :: 3.8
42
+ Classifier: Programming Language :: Python :: 3.9
43
+ Classifier: Programming Language :: Python :: 3.10
44
+ Classifier: Programming Language :: Python :: 3.11
45
+ Classifier: Programming Language :: Python :: 3.12
46
+ Classifier: Framework :: AsyncIO
47
+ Requires-Python: >=3.8
48
+ Description-Content-Type: text/markdown
49
+ License-File: LICENSE
50
+ Requires-Dist: aiohttp>=3.8.0
51
+ Dynamic: license-file
52
+
53
+ # πŸš€ BROKENXAPI
54
+
55
+ **Official Async Python SDK for BrokenX YouTube API**
56
+
57
+ <p align="center">
58
+ <strong>Fast β€’ Secure β€’ Async β€’ Production-Ready</strong>
59
+ </p>
60
+
61
+ ---
62
+
63
+ ## πŸ“Œ Overview
64
+
65
+ **BROKENXAPI** is the official asynchronous Python SDK for the **BrokenX YouTube API**,
66
+ designed for developers who want a **simple, secure, and scalable** way to search and download YouTube media via BrokenX’s backend infrastructure.
67
+
68
+ The SDK abstracts all backend complexity and exposes a **clean, minimal interface** that works with nothing more than an API key.
69
+
70
+ > ⚠️ Backend logic, infrastructure, and internal mechanisms are intentionally not exposed.
71
+
72
+ ---
73
+
74
+ ## ✨ Key Features
75
+
76
+ * ⚑ **Async-first** (built on `aiohttp`)
77
+ * πŸ” **Secure header-based authentication**
78
+ * 🧼 **Clean SDK interface** (no base URLs or backend details required)
79
+ * 🚫 **No logic exposure** (protected client implementation)
80
+ * πŸ“¦ **PyPI-ready & production-stable**
81
+ * πŸ“‘ **Telegram-backed media delivery**
82
+ * 🧠 **Rate-limit & usage tracking enforced server-side**
83
+
84
+ ---
85
+
86
+ ## πŸ“¦ Installation
87
+
88
+ Install directly from PyPI:
89
+
90
+ ```bash
91
+ pip install BROKENXAPI
92
+ ```
93
+
94
+ ### Requirements
95
+
96
+ * Python **3.8+**
97
+ * Valid **BROKENXAPI** key
98
+ * Internet access
99
+
100
+ ---
101
+
102
+ ## πŸ”‘ Authentication
103
+
104
+ BROKENXAPI uses **header-based authentication**.
105
+
106
+ You only need to provide your API key when creating the client.
107
+
108
+ ```text
109
+ Authorization: Bearer YOUR_API_KEY
110
+ ```
111
+
112
+ * API keys are issued by **Broken X Network**
113
+ * Never share your API key publicly
114
+ * Rate limits are enforced automatically
115
+
116
+ ---
117
+
118
+ ## πŸš€ Quick Start
119
+
120
+ ```python
121
+ import asyncio
122
+ from brokenxapi import BrokenXAPI
123
+
124
+ async def main():
125
+ async with BrokenXAPI(
126
+ api_key="BROKENXAPI-XXXX"
127
+ ) as api:
128
+
129
+ result = await api.search("Arijit Singh")
130
+ print(result)
131
+
132
+ asyncio.run(main())
133
+ ```
134
+
135
+ That’s it.
136
+ No base URL. No configuration. No setup noise.
137
+
138
+ ---
139
+
140
+ ## πŸ” Search API
141
+
142
+ Search YouTube content using BrokenX backend.
143
+
144
+ ### Example
145
+
146
+ ```python
147
+ await api.search("lofi beats", video=False)
148
+ ```
149
+
150
+ ### Parameters
151
+
152
+ | Name | Type | Description |
153
+ | ------- | ------ | ------------------------------- |
154
+ | `query` | `str` | Search keyword |
155
+ | `video` | `bool` | `False` = audio, `True` = video |
156
+
157
+ ### Response (Example)
158
+
159
+ ```json
160
+ {
161
+ "success": true,
162
+ "status": "found",
163
+ "title": "Lofi Beats",
164
+ "video_id": "abcd1234",
165
+ "duration": "3:24",
166
+ "thumbnail": "https://...",
167
+ "stream_url": "https://youtube.com/watch?v=abcd1234"
168
+ }
169
+ ```
170
+
171
+ ---
172
+
173
+ ## ⬇️ Download API
174
+
175
+ Download audio or video using BrokenX’s processing pipeline.
176
+
177
+ ### Audio Download
178
+
179
+ ```python
180
+ await api.download("VIDEO_ID", media_type="audio")
181
+ ```
182
+
183
+ ### Video Download
184
+
185
+ ```python
186
+ await api.download("VIDEO_ID", media_type="video")
187
+ ```
188
+
189
+ ### Notes
190
+
191
+ * Files are delivered via **Telegram hosting**
192
+ * Cached results may be returned instantly
193
+ * Backend handles format selection and optimization
194
+
195
+ ---
196
+
197
+ ## ⚠️ Error Handling
198
+
199
+ All SDK errors inherit from `BrokenXAPIError`.
200
+
201
+ ```python
202
+ from brokenxapi.exceptions import BrokenXAPIError
203
+
204
+ try:
205
+ await api.download("invalid_id")
206
+ except BrokenXAPIError as e:
207
+ print("Error:", e)
208
+ ```
209
+
210
+ ### Common Errors
211
+
212
+ * Invalid API key
213
+ * Rate limit exceeded
214
+ * Backend processing failure
215
+ * Network errors
216
+
217
+ ---
218
+
219
+ ## 🧠 Design Philosophy
220
+
221
+ BROKENXAPI follows a **backend-first security model**:
222
+
223
+ * SDK = **thin, controlled client**
224
+ * Backend = **source of truth**
225
+ * Logic is intentionally protected
226
+ * API keys are validated server-side only
227
+
228
+ > Even if the SDK is copied, backend security remains intact.
229
+
230
+ ---
231
+
232
+ ## πŸ“ Documentation
233
+
234
+ Full documentation is available in the [`docs/`](./docs) directory:
235
+
236
+ * Installation
237
+ * Authentication
238
+ * Search API
239
+ * Download API
240
+ * Examples
241
+ * Changelog
242
+
243
+ ---
244
+
245
+ ## 🧩 Versioning
246
+
247
+ This project follows **semantic versioning**.
248
+
249
+ | Version | Meaning |
250
+ | ------- | ---------------- |
251
+ | `MAJOR` | Breaking changes |
252
+ | `MINOR` | New features |
253
+ | `PATCH` | Bug fixes |
254
+
255
+ Current version: **v2.0.0**
256
+
257
+ ---
258
+
259
+ ## πŸ“œ License
260
+
261
+ This project is licensed under the **MIT License**.
262
+
263
+ ```
264
+ Β© 2025–2026 MR BROKEN
265
+ All Rights Reserved
266
+ ```
267
+
268
+ ---
269
+
270
+ ## 🏁 Final Notes
271
+
272
+ * BROKENXAPI is designed for **developers, bots, and backend services**
273
+ * Not intended for browser-side usage
274
+ * Abuse, scraping, or misuse may result in key revocation
275
+
276
+ ---
277
+
@@ -0,0 +1,16 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ BROKENXAPI.egg-info/PKG-INFO
6
+ BROKENXAPI.egg-info/SOURCES.txt
7
+ BROKENXAPI.egg-info/dependency_links.txt
8
+ BROKENXAPI.egg-info/entry_points.txt
9
+ BROKENXAPI.egg-info/not-zip-safe
10
+ BROKENXAPI.egg-info/requires.txt
11
+ BROKENXAPI.egg-info/top_level.txt
12
+ brokenxapi/__init__.py
13
+ brokenxapi/__version__.py
14
+ brokenxapi/cli.py
15
+ brokenxapi/exceptions.py
16
+ brokenxapi/models.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ brokenx = brokenxapi.cli:main
@@ -0,0 +1 @@
1
+ aiohttp>=3.8.0
@@ -0,0 +1 @@
1
+ brokenxapi
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mr Broken
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,277 @@
1
+ Metadata-Version: 2.4
2
+ Name: BROKENXAPI
3
+ Version: 2.0.0
4
+ Summary: Official async Python SDK and CLI for BrokenX YouTube API
5
+ Author-email: Mr Broken <brokenxnetwork@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Mr Broken
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/BrokenXNetwork/BROKENXAPI
29
+ Project-URL: Repository, https://github.com/BrokenXNetwork/BROKENXAPI
30
+ Project-URL: Documentation, https://brokenxapi-docs.vercel.app
31
+ Project-URL: Issues, https://github.com/BrokenXNetwork/BROKENXAPI/issues
32
+ Keywords: brokenx,youtube,api,async,sdk,cli,aiohttp,telegram
33
+ Classifier: Development Status :: 5 - Production/Stable
34
+ Classifier: Intended Audience :: Developers
35
+ Classifier: Topic :: Software Development :: Libraries
36
+ Classifier: Topic :: Multimedia :: Video
37
+ Classifier: License :: OSI Approved :: MIT License
38
+ Classifier: Operating System :: OS Independent
39
+ Classifier: Programming Language :: Python :: 3
40
+ Classifier: Programming Language :: Python :: 3 :: Only
41
+ Classifier: Programming Language :: Python :: 3.8
42
+ Classifier: Programming Language :: Python :: 3.9
43
+ Classifier: Programming Language :: Python :: 3.10
44
+ Classifier: Programming Language :: Python :: 3.11
45
+ Classifier: Programming Language :: Python :: 3.12
46
+ Classifier: Framework :: AsyncIO
47
+ Requires-Python: >=3.8
48
+ Description-Content-Type: text/markdown
49
+ License-File: LICENSE
50
+ Requires-Dist: aiohttp>=3.8.0
51
+ Dynamic: license-file
52
+
53
+ # πŸš€ BROKENXAPI
54
+
55
+ **Official Async Python SDK for BrokenX YouTube API**
56
+
57
+ <p align="center">
58
+ <strong>Fast β€’ Secure β€’ Async β€’ Production-Ready</strong>
59
+ </p>
60
+
61
+ ---
62
+
63
+ ## πŸ“Œ Overview
64
+
65
+ **BROKENXAPI** is the official asynchronous Python SDK for the **BrokenX YouTube API**,
66
+ designed for developers who want a **simple, secure, and scalable** way to search and download YouTube media via BrokenX’s backend infrastructure.
67
+
68
+ The SDK abstracts all backend complexity and exposes a **clean, minimal interface** that works with nothing more than an API key.
69
+
70
+ > ⚠️ Backend logic, infrastructure, and internal mechanisms are intentionally not exposed.
71
+
72
+ ---
73
+
74
+ ## ✨ Key Features
75
+
76
+ * ⚑ **Async-first** (built on `aiohttp`)
77
+ * πŸ” **Secure header-based authentication**
78
+ * 🧼 **Clean SDK interface** (no base URLs or backend details required)
79
+ * 🚫 **No logic exposure** (protected client implementation)
80
+ * πŸ“¦ **PyPI-ready & production-stable**
81
+ * πŸ“‘ **Telegram-backed media delivery**
82
+ * 🧠 **Rate-limit & usage tracking enforced server-side**
83
+
84
+ ---
85
+
86
+ ## πŸ“¦ Installation
87
+
88
+ Install directly from PyPI:
89
+
90
+ ```bash
91
+ pip install BROKENXAPI
92
+ ```
93
+
94
+ ### Requirements
95
+
96
+ * Python **3.8+**
97
+ * Valid **BROKENXAPI** key
98
+ * Internet access
99
+
100
+ ---
101
+
102
+ ## πŸ”‘ Authentication
103
+
104
+ BROKENXAPI uses **header-based authentication**.
105
+
106
+ You only need to provide your API key when creating the client.
107
+
108
+ ```text
109
+ Authorization: Bearer YOUR_API_KEY
110
+ ```
111
+
112
+ * API keys are issued by **Broken X Network**
113
+ * Never share your API key publicly
114
+ * Rate limits are enforced automatically
115
+
116
+ ---
117
+
118
+ ## πŸš€ Quick Start
119
+
120
+ ```python
121
+ import asyncio
122
+ from brokenxapi import BrokenXAPI
123
+
124
+ async def main():
125
+ async with BrokenXAPI(
126
+ api_key="BROKENXAPI-XXXX"
127
+ ) as api:
128
+
129
+ result = await api.search("Arijit Singh")
130
+ print(result)
131
+
132
+ asyncio.run(main())
133
+ ```
134
+
135
+ That’s it.
136
+ No base URL. No configuration. No setup noise.
137
+
138
+ ---
139
+
140
+ ## πŸ” Search API
141
+
142
+ Search YouTube content using BrokenX backend.
143
+
144
+ ### Example
145
+
146
+ ```python
147
+ await api.search("lofi beats", video=False)
148
+ ```
149
+
150
+ ### Parameters
151
+
152
+ | Name | Type | Description |
153
+ | ------- | ------ | ------------------------------- |
154
+ | `query` | `str` | Search keyword |
155
+ | `video` | `bool` | `False` = audio, `True` = video |
156
+
157
+ ### Response (Example)
158
+
159
+ ```json
160
+ {
161
+ "success": true,
162
+ "status": "found",
163
+ "title": "Lofi Beats",
164
+ "video_id": "abcd1234",
165
+ "duration": "3:24",
166
+ "thumbnail": "https://...",
167
+ "stream_url": "https://youtube.com/watch?v=abcd1234"
168
+ }
169
+ ```
170
+
171
+ ---
172
+
173
+ ## ⬇️ Download API
174
+
175
+ Download audio or video using BrokenX’s processing pipeline.
176
+
177
+ ### Audio Download
178
+
179
+ ```python
180
+ await api.download("VIDEO_ID", media_type="audio")
181
+ ```
182
+
183
+ ### Video Download
184
+
185
+ ```python
186
+ await api.download("VIDEO_ID", media_type="video")
187
+ ```
188
+
189
+ ### Notes
190
+
191
+ * Files are delivered via **Telegram hosting**
192
+ * Cached results may be returned instantly
193
+ * Backend handles format selection and optimization
194
+
195
+ ---
196
+
197
+ ## ⚠️ Error Handling
198
+
199
+ All SDK errors inherit from `BrokenXAPIError`.
200
+
201
+ ```python
202
+ from brokenxapi.exceptions import BrokenXAPIError
203
+
204
+ try:
205
+ await api.download("invalid_id")
206
+ except BrokenXAPIError as e:
207
+ print("Error:", e)
208
+ ```
209
+
210
+ ### Common Errors
211
+
212
+ * Invalid API key
213
+ * Rate limit exceeded
214
+ * Backend processing failure
215
+ * Network errors
216
+
217
+ ---
218
+
219
+ ## 🧠 Design Philosophy
220
+
221
+ BROKENXAPI follows a **backend-first security model**:
222
+
223
+ * SDK = **thin, controlled client**
224
+ * Backend = **source of truth**
225
+ * Logic is intentionally protected
226
+ * API keys are validated server-side only
227
+
228
+ > Even if the SDK is copied, backend security remains intact.
229
+
230
+ ---
231
+
232
+ ## πŸ“ Documentation
233
+
234
+ Full documentation is available in the [`docs/`](./docs) directory:
235
+
236
+ * Installation
237
+ * Authentication
238
+ * Search API
239
+ * Download API
240
+ * Examples
241
+ * Changelog
242
+
243
+ ---
244
+
245
+ ## 🧩 Versioning
246
+
247
+ This project follows **semantic versioning**.
248
+
249
+ | Version | Meaning |
250
+ | ------- | ---------------- |
251
+ | `MAJOR` | Breaking changes |
252
+ | `MINOR` | New features |
253
+ | `PATCH` | Bug fixes |
254
+
255
+ Current version: **v2.0.0**
256
+
257
+ ---
258
+
259
+ ## πŸ“œ License
260
+
261
+ This project is licensed under the **MIT License**.
262
+
263
+ ```
264
+ Β© 2025–2026 MR BROKEN
265
+ All Rights Reserved
266
+ ```
267
+
268
+ ---
269
+
270
+ ## 🏁 Final Notes
271
+
272
+ * BROKENXAPI is designed for **developers, bots, and backend services**
273
+ * Not intended for browser-side usage
274
+ * Abuse, scraping, or misuse may result in key revocation
275
+
276
+ ---
277
+
@@ -0,0 +1,225 @@
1
+ # πŸš€ BROKENXAPI
2
+
3
+ **Official Async Python SDK for BrokenX YouTube API**
4
+
5
+ <p align="center">
6
+ <strong>Fast β€’ Secure β€’ Async β€’ Production-Ready</strong>
7
+ </p>
8
+
9
+ ---
10
+
11
+ ## πŸ“Œ Overview
12
+
13
+ **BROKENXAPI** is the official asynchronous Python SDK for the **BrokenX YouTube API**,
14
+ designed for developers who want a **simple, secure, and scalable** way to search and download YouTube media via BrokenX’s backend infrastructure.
15
+
16
+ The SDK abstracts all backend complexity and exposes a **clean, minimal interface** that works with nothing more than an API key.
17
+
18
+ > ⚠️ Backend logic, infrastructure, and internal mechanisms are intentionally not exposed.
19
+
20
+ ---
21
+
22
+ ## ✨ Key Features
23
+
24
+ * ⚑ **Async-first** (built on `aiohttp`)
25
+ * πŸ” **Secure header-based authentication**
26
+ * 🧼 **Clean SDK interface** (no base URLs or backend details required)
27
+ * 🚫 **No logic exposure** (protected client implementation)
28
+ * πŸ“¦ **PyPI-ready & production-stable**
29
+ * πŸ“‘ **Telegram-backed media delivery**
30
+ * 🧠 **Rate-limit & usage tracking enforced server-side**
31
+
32
+ ---
33
+
34
+ ## πŸ“¦ Installation
35
+
36
+ Install directly from PyPI:
37
+
38
+ ```bash
39
+ pip install BROKENXAPI
40
+ ```
41
+
42
+ ### Requirements
43
+
44
+ * Python **3.8+**
45
+ * Valid **BROKENXAPI** key
46
+ * Internet access
47
+
48
+ ---
49
+
50
+ ## πŸ”‘ Authentication
51
+
52
+ BROKENXAPI uses **header-based authentication**.
53
+
54
+ You only need to provide your API key when creating the client.
55
+
56
+ ```text
57
+ Authorization: Bearer YOUR_API_KEY
58
+ ```
59
+
60
+ * API keys are issued by **Broken X Network**
61
+ * Never share your API key publicly
62
+ * Rate limits are enforced automatically
63
+
64
+ ---
65
+
66
+ ## πŸš€ Quick Start
67
+
68
+ ```python
69
+ import asyncio
70
+ from brokenxapi import BrokenXAPI
71
+
72
+ async def main():
73
+ async with BrokenXAPI(
74
+ api_key="BROKENXAPI-XXXX"
75
+ ) as api:
76
+
77
+ result = await api.search("Arijit Singh")
78
+ print(result)
79
+
80
+ asyncio.run(main())
81
+ ```
82
+
83
+ That’s it.
84
+ No base URL. No configuration. No setup noise.
85
+
86
+ ---
87
+
88
+ ## πŸ” Search API
89
+
90
+ Search YouTube content using BrokenX backend.
91
+
92
+ ### Example
93
+
94
+ ```python
95
+ await api.search("lofi beats", video=False)
96
+ ```
97
+
98
+ ### Parameters
99
+
100
+ | Name | Type | Description |
101
+ | ------- | ------ | ------------------------------- |
102
+ | `query` | `str` | Search keyword |
103
+ | `video` | `bool` | `False` = audio, `True` = video |
104
+
105
+ ### Response (Example)
106
+
107
+ ```json
108
+ {
109
+ "success": true,
110
+ "status": "found",
111
+ "title": "Lofi Beats",
112
+ "video_id": "abcd1234",
113
+ "duration": "3:24",
114
+ "thumbnail": "https://...",
115
+ "stream_url": "https://youtube.com/watch?v=abcd1234"
116
+ }
117
+ ```
118
+
119
+ ---
120
+
121
+ ## ⬇️ Download API
122
+
123
+ Download audio or video using BrokenX’s processing pipeline.
124
+
125
+ ### Audio Download
126
+
127
+ ```python
128
+ await api.download("VIDEO_ID", media_type="audio")
129
+ ```
130
+
131
+ ### Video Download
132
+
133
+ ```python
134
+ await api.download("VIDEO_ID", media_type="video")
135
+ ```
136
+
137
+ ### Notes
138
+
139
+ * Files are delivered via **Telegram hosting**
140
+ * Cached results may be returned instantly
141
+ * Backend handles format selection and optimization
142
+
143
+ ---
144
+
145
+ ## ⚠️ Error Handling
146
+
147
+ All SDK errors inherit from `BrokenXAPIError`.
148
+
149
+ ```python
150
+ from brokenxapi.exceptions import BrokenXAPIError
151
+
152
+ try:
153
+ await api.download("invalid_id")
154
+ except BrokenXAPIError as e:
155
+ print("Error:", e)
156
+ ```
157
+
158
+ ### Common Errors
159
+
160
+ * Invalid API key
161
+ * Rate limit exceeded
162
+ * Backend processing failure
163
+ * Network errors
164
+
165
+ ---
166
+
167
+ ## 🧠 Design Philosophy
168
+
169
+ BROKENXAPI follows a **backend-first security model**:
170
+
171
+ * SDK = **thin, controlled client**
172
+ * Backend = **source of truth**
173
+ * Logic is intentionally protected
174
+ * API keys are validated server-side only
175
+
176
+ > Even if the SDK is copied, backend security remains intact.
177
+
178
+ ---
179
+
180
+ ## πŸ“ Documentation
181
+
182
+ Full documentation is available in the [`docs/`](./docs) directory:
183
+
184
+ * Installation
185
+ * Authentication
186
+ * Search API
187
+ * Download API
188
+ * Examples
189
+ * Changelog
190
+
191
+ ---
192
+
193
+ ## 🧩 Versioning
194
+
195
+ This project follows **semantic versioning**.
196
+
197
+ | Version | Meaning |
198
+ | ------- | ---------------- |
199
+ | `MAJOR` | Breaking changes |
200
+ | `MINOR` | New features |
201
+ | `PATCH` | Bug fixes |
202
+
203
+ Current version: **v2.0.0**
204
+
205
+ ---
206
+
207
+ ## πŸ“œ License
208
+
209
+ This project is licensed under the **MIT License**.
210
+
211
+ ```
212
+ Β© 2025–2026 MR BROKEN
213
+ All Rights Reserved
214
+ ```
215
+
216
+ ---
217
+
218
+ ## 🏁 Final Notes
219
+
220
+ * BROKENXAPI is designed for **developers, bots, and backend services**
221
+ * Not intended for browser-side usage
222
+ * Abuse, scraping, or misuse may result in key revocation
223
+
224
+ ---
225
+
@@ -0,0 +1,4 @@
1
+ from .client import BrokenXAPI
2
+
3
+ __all__ = ["BrokenXAPI"]
4
+
@@ -0,0 +1,2 @@
1
+ __version__ = "2.0.0"
2
+
@@ -0,0 +1,129 @@
1
+ import argparse
2
+ import asyncio
3
+ import json
4
+ import os
5
+ import sys
6
+ import stat
7
+ import importlib.metadata
8
+ from pathlib import Path
9
+
10
+ from brokenxapi import BrokenXAPI
11
+ from brokenxapi.exceptions import BrokenXAPIError
12
+
13
+ CONFIG_DIR = Path.home() / ".brokenx"
14
+ CONFIG_FILE = CONFIG_DIR / "config.json"
15
+
16
+
17
+ # ---------------- CONFIG HELPERS ----------------
18
+
19
+ def save_api_key(api_key: str):
20
+ CONFIG_DIR.mkdir(exist_ok=True)
21
+ CONFIG_FILE.write_text(json.dumps({"api_key": api_key}))
22
+ CONFIG_FILE.chmod(stat.S_IRUSR | stat.S_IWUSR) # 600
23
+
24
+
25
+ def load_api_key():
26
+ if not CONFIG_FILE.exists():
27
+ return None
28
+ try:
29
+ data = json.loads(CONFIG_FILE.read_text())
30
+ return data.get("api_key")
31
+ except Exception:
32
+ return None
33
+
34
+
35
+ def require_api_key():
36
+ key = load_api_key()
37
+ if not key:
38
+ print(
39
+ "❌ Not authenticated.\n"
40
+ "Run: brokenx auth <YOUR_API_KEY>",
41
+ file=sys.stderr,
42
+ )
43
+ sys.exit(1)
44
+ return key
45
+
46
+
47
+ # ---------------- CLI CORE ----------------
48
+
49
+ async def run_cli():
50
+ parser = argparse.ArgumentParser(
51
+ prog="brokenx",
52
+ description="BROKENXAPI Command Line Interface",
53
+ )
54
+
55
+ parser.add_argument(
56
+ "-v", "--version",
57
+ action="store_true",
58
+ help="Show BROKENXAPI version",
59
+ )
60
+
61
+ sub = parser.add_subparsers(dest="command")
62
+
63
+ # ---------- AUTH ----------
64
+ auth_cmd = sub.add_parser("auth", help="Authenticate with API key")
65
+ auth_cmd.add_argument("api_key", help="Your BROKENXAPI key")
66
+
67
+ # ---------- SEARCH ----------
68
+ search_cmd = sub.add_parser("search", help="Search YouTube")
69
+ search_cmd.add_argument("query", help="Search query")
70
+
71
+ # ---------- DOWNLOAD ----------
72
+ download_cmd = sub.add_parser("download", help="Download media")
73
+ download_cmd.add_argument("video_id", help="YouTube video ID")
74
+ download_cmd.add_argument(
75
+ "-v", "--video",
76
+ action="store_true",
77
+ help="Download video instead of audio",
78
+ )
79
+
80
+ args = parser.parse_args()
81
+
82
+ # ---------------- VERSION ----------------
83
+ if args.version:
84
+ print(importlib.metadata.version("BROKENXAPI"))
85
+ return
86
+
87
+ # ---------------- AUTH ----------------
88
+ if args.command == "auth":
89
+ try:
90
+ # πŸ” Verify key by doing a lightweight call
91
+ async with BrokenXAPI(api_key=args.api_key) as api:
92
+ await api.search("test") # harmless validation
93
+ save_api_key(args.api_key)
94
+ print("βœ… Authentication successful. API key saved.")
95
+ except BrokenXAPIError as e:
96
+ print(f"❌ Authentication failed: {e}", file=sys.stderr)
97
+ sys.exit(1)
98
+ return
99
+
100
+ # ---------------- OTHER COMMANDS ----------------
101
+ api_key = require_api_key()
102
+
103
+ async with BrokenXAPI(api_key=api_key) as api:
104
+ if args.command == "search":
105
+ result = await api.search(args.query)
106
+ print(json.dumps(result, indent=2))
107
+ return
108
+
109
+ if args.command == "download":
110
+ media_type = "video" if args.video else "audio"
111
+ result = await api.download(args.video_id, media_type)
112
+ print(json.dumps(result, indent=2))
113
+ return
114
+
115
+ parser.print_help()
116
+
117
+
118
+ def main():
119
+ try:
120
+ asyncio.run(run_cli())
121
+ except KeyboardInterrupt:
122
+ pass
123
+ except BrokenXAPIError as e:
124
+ print(f"❌ {e}", file=sys.stderr)
125
+ sys.exit(1)
126
+
127
+
128
+ if __name__ == "__main__":
129
+ main()
@@ -0,0 +1,11 @@
1
+ class BrokenXAPIError(Exception):
2
+ pass
3
+
4
+ class AuthenticationError(BrokenXAPIError):
5
+ pass
6
+
7
+ class RateLimitError(BrokenXAPIError):
8
+ pass
9
+
10
+ class ServerError(BrokenXAPIError):
11
+ pass
@@ -0,0 +1,19 @@
1
+ from typing import TypedDict
2
+
3
+ class DownloadResponse(TypedDict, total=False):
4
+ success: bool
5
+ status: str
6
+ video_id: str
7
+ type: str
8
+ telegram_url: str
9
+ thumbnail: str
10
+ source: str
11
+
12
+ class SearchResponse(TypedDict, total=False):
13
+ success: bool
14
+ status: str
15
+ title: str
16
+ video_id: str
17
+ duration: str
18
+ thumbnail: str
19
+ stream_url: str
@@ -0,0 +1,70 @@
1
+ [project]
2
+ name = "BROKENXAPI"
3
+ dynamic = ["version"]
4
+ description = "Official async Python SDK and CLI for BrokenX YouTube API"
5
+ readme = "README.md"
6
+ license = { file = "LICENSE" }
7
+
8
+ authors = [
9
+ { name = "Mr Broken", email = "brokenxnetwork@gmail.com" }
10
+ ]
11
+
12
+ keywords = [
13
+ "brokenx",
14
+ "youtube",
15
+ "api",
16
+ "async",
17
+ "sdk",
18
+ "cli",
19
+ "aiohttp",
20
+ "telegram"
21
+ ]
22
+
23
+ classifiers = [
24
+ "Development Status :: 5 - Production/Stable",
25
+ "Intended Audience :: Developers",
26
+
27
+ "Topic :: Software Development :: Libraries",
28
+ "Topic :: Multimedia :: Video",
29
+
30
+ "License :: OSI Approved :: MIT License",
31
+ "Operating System :: OS Independent",
32
+
33
+ "Programming Language :: Python :: 3",
34
+ "Programming Language :: Python :: 3 :: Only",
35
+ "Programming Language :: Python :: 3.8",
36
+ "Programming Language :: Python :: 3.9",
37
+ "Programming Language :: Python :: 3.10",
38
+ "Programming Language :: Python :: 3.11",
39
+ "Programming Language :: Python :: 3.12",
40
+
41
+ "Framework :: AsyncIO"
42
+ ]
43
+
44
+ requires-python = ">=3.8"
45
+
46
+ dependencies = [
47
+ "aiohttp>=3.8.0"
48
+ ]
49
+
50
+ [project.urls]
51
+ Homepage = "https://github.com/BrokenXNetwork/BROKENXAPI"
52
+ Repository = "https://github.com/BrokenXNetwork/BROKENXAPI"
53
+ Documentation = "https://brokenxapi-docs.vercel.app"
54
+ Issues = "https://github.com/BrokenXNetwork/BROKENXAPI/issues"
55
+
56
+ # ---------------- CLI ENTRY ----------------
57
+ [project.scripts]
58
+ brokenx = "brokenxapi.cli:main"
59
+
60
+ # ---------------- SETUPTOOLS ----------------
61
+ [tool.setuptools]
62
+ include-package-data = true
63
+
64
+ [tool.setuptools.packages.find]
65
+ include = ["brokenxapi*"]
66
+
67
+ # ---------------- BUILD SYSTEM ----------------
68
+ [build-system]
69
+ requires = ["setuptools>=69.0", "wheel>=0.43.0"]
70
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,15 @@
1
+ from setuptools import setup
2
+ import os
3
+
4
+ about = {}
5
+
6
+ here = os.path.abspath(os.path.dirname(__file__))
7
+ version_file = os.path.join(here, "brokenxapi", "__version__.py")
8
+
9
+ with open(version_file, encoding="utf-8") as f:
10
+ exec(f.read(), about)
11
+
12
+ setup(
13
+ version=about["__version__"],
14
+ zip_safe=False,
15
+ )