# ytq
`ytq` is a lightweight and fast Python library for searching YouTube videos using the official MWeb API.
It supports both synchronous and asynchronous usage, making it suitable for scripts, bots, and larger applications.
---
## Features
- Simple and fast YouTube search
- Asynchronous and synchronous support
- Returns structured JSON results
- Includes video title, ID, URL, and thumbnail
- Supports result limiting (`limit` parameter)
- Works without any API keys
---
## Installation
You can install `ytq` from PyPI (after publishing):
```bash
pip install ytq
Or from source:
git clone https://github.com/ahmeddreas/ytq.git
cd ytq
pip install .
Example Usage
Synchronous
from ytq import search
results = search("lofi music", limit=5)
for video in results:
print(video["title"], video["url"])
Asynchronous
import asyncio
from ytq import asearch
async def main():
results = await asearch("python tutorials", limit=3)
print(results[0]["title"], results[0]["url"])
asyncio.run(main())
Parameters
| Parameter | Type | Description |
|---|---|---|
query |
str |
The search query (e.g., "python programming") |
limit |
int or None |
Number of results to return. If None, returns all available results. |
auto_print |
bool |
If True, prints formatted results to console. Default is True. |
Returned JSON Structure
Each search result is a dictionary with the following keys:
{
"video_id": "abcd1234",
"title": "Example video title",
"url": "https://m.youtube.com/watch?v=abcd1234",
"thumbnail": "https://i.ytimg.com/vi/abcd1234/hqdefault.jpg"
}
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Author
Ahmed D. Ismail GitHub: Ahmed d. Ismail
Metadata
Release files for ytq-search 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ytq_search-0.1.1.tar.gz | 2.3 kB | Without provenance | Details for ytq_search-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ytq_search-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for ytq_search-0.1.1-py3-none-any.whl |
Total release size: 4.4 kB
Release files / ytq_search-0.1.1.tar.gz
| Download URL | ytq_search-0.1.1.tar.gz |
|---|---|
| Size | 2.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3019c3fd11e161841098361759874bc8c2d956a95670d5ee1f06bebff097f12c
|
|
BLAKE2b-256 checksum How to use checksums |
56640b7641f30ce2ed46df0a282f11bcd292513cbf6dec3247e90f746267e5b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / ytq_search-0.1.1-py3-none-any.whl
| Download URL | ytq_search-0.1.1-py3-none-any.whl |
|---|---|
| Size | 2.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8521a82fee35dadce05cfd560c0ccfc282215bbe0a869c73bce159128dfa2e2c
|
|
BLAKE2b-256 checksum How to use checksums |
8c67a604a6701df7438456ef46e8256025903957826b70fe8d504c45c1772f06
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for ytq-search 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.