https://github.com/madeyoga/ytpy
Python asynchronous wrapper for searching for youtube videos.
https://github.com/madeyoga/ytpy
asynchronous search youtube youtube-music youtube-search youtubesearch
Last synced: 2 days ago
JSON representation
Python asynchronous wrapper for searching for youtube videos.
- Host: GitHub
- URL: https://github.com/madeyoga/ytpy
- Owner: madeyoga
- License: mit
- Created: 2019-01-20T14:22:59.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-05-11T11:03:43.000Z (over 3 years ago)
- Last Synced: 2025-09-25T01:53:44.255Z (14 days ago)
- Topics: asynchronous, search, youtube, youtube-music, youtube-search, youtubesearch
- Language: Python
- Homepage:
- Size: 89.8 KB
- Stars: 20
- Watchers: 3
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# ytpy
[](https://www.codefactor.io/repository/github/madeyoga/ytpy)
[](https://pepy.tech/project/ytpy)

[](https://github.com/MadeYoga/aio-ytpy/issues)
[](https://discord.gg/Y8sB4ay)Python wrapper to extract youtube data. Simple *asynchronous* wrapper to get youtube video or playlist data.
The purpose of this project is to make it easier for developers to extract data from YouTube.## Requirements
- Python 3.x
- [Get Google API' Credential 'API KEY'](https://developers.google.com/youtube/registering_an_application) for `YoutubeDataApiV3Client` only## Dependencies
- urllib
- aiohttp## Install
```bash
pip install --upgrade ytpy
```### Usage
```py
from ytpy import YoutubeClient
import asyncio
import aiohttpasync def main(loop):
session = aiohttp.ClientSession()client = YoutubeClient(session)
response = await client.search('ringtone')
print(response)await session.close()
loop = asyncio.get_event_loop()
loop.run_until_complete(main(loop))```
### Search Video by `Keywords` using YoutubeDataApiV3Client
https://developers.google.com/youtube/v3/docs/searchparams:
- `q`, string. Search key. default: empty string.
- `part`, string. Valid parts: snippet, contentDetails, player, statistics, status. default: snippet.
- `type`, string. Valid types: video, playlist, channel.Example `Search` method
```py
import os
import asyncio
import aiohttp
from ytpy import YoutubeDataApiV3Clientasync def main(loop):
session = aiohttp.ClientSession()
# Pass the aiohttp client session
ayt = YoutubeDataApiV3Client(session, dev_key=os.environ["DEVELOPER_KEY"])
# test search
results = await ayt.search(q="d&e lost",
search_type="video",
max_results=1)
print(results)await session.close()
loop = asyncio.get_event_loop()
loop.run_until_complete(main(loop))
loop.close()
```### Examples
Check [examples](https://github.com/madeyoga/ytpy/tree/master/examples) for the full code example## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.Please make sure to update tests/examples as appropriate.