Skip to main content

A basic, asynchronous, object-oriented YouTube API wrapper written in Python.

Project description

PyPI PyPI - Python Version GitHub release (latest by date) PyPI - Downloads per month Supported Python Versions Repo Created At

ayt-api

A Basic, Asynchronous, Object-Oriented YouTube API Wrapper Written in Python.

The library is designed towards being used in python based discord bots that use an asynchronous discord api wrapper

Installation

Stable Release:

The latest stable version is available on pypi

Windows:

python -m pip install -U ayt-api

Unix based OSes (Linux, Mac OS, etc.):

The pip command can vary between different unix based OSes but should be simular to these:

python3 -m pip install -U ayt-api

# or

pip3 install -U ayt-api

Latest Commit:

Installing the latest commit from here. You will need git or something simular installed to download the library

Windows:

python -m pip install -U "git+https://github.com/Revnoplex/ayt-api.git"

Unix based OSes (Linux, Mac OS, etc.):

The pip command can vary between diffrent unix based OSes but should be simular to these:

python3 -m pip install -U git+https://github.com/Revnoplex/ayt-api.git

# or

pip3 install -U git+https://github.com/Revnoplex/ayt-api.git

Usage

First of all to use this library, you will need an API key. To get one, see here for instructions

Basic video data fetching:

import asyncio
import ayt_api

api = ayt_api.AsyncYoutubeAPI("Your API Key")


async def video_example():
    video_data = await api.fetch_video("Video ID")
    print(video_data.id)
    print(video_data.channel_id)
    print(video_data.url)
    print(video_data.title)
    print(video_data.thumbnails.default.url)
    print(video_data.visibility)
    print(video_data.duration)
    print(video_data.view_count)
    print(video_data.like_count)
    print(video_data.embed_html)
    print(video_data.published_at)
    print(video_data.description)
    print(video_data.age_restricted)

loop = asyncio.new_event_loop()
loop.run_until_complete(video_example())

Basic playlist data fetching:

import asyncio
import ayt_api

api = ayt_api.AsyncYoutubeAPI("Your API Key")


async def playlist_example():
    playlist_data = await api.fetch_playlist("Playlist ID")
    print(playlist_data.id)
    print(playlist_data.channel_id)
    print(playlist_data.url)
    print(playlist_data.title)
    print(playlist_data.thumbnails.default.url)
    print(playlist_data.visibility)
    print(playlist_data.published_at)
    print(playlist_data.description)
    print(playlist_data.embed_html)
    print(playlist_data.item_count)

loop = asyncio.new_event_loop()
loop.run_until_complete(playlist_example())

Basic playlist video fetching:

import asyncio
import ayt_api

api = ayt_api.AsyncYoutubeAPI("Your API Key")


async def playlist_video_example():
    playlist_videos = await api.fetch_playlist_videos("Playlist ID")
    video = playlist_videos[0]
    print(video.id)
    print(video.channel_id)
    print(video.url)
    print(video.title)
    print(video.thumbnails.default.url)
    print(video.visibility)
    print(video.published_at)
    print(video.description)
    print(video.duration)

loop = asyncio.new_event_loop()
loop.run_until_complete(playlist_video_example())

More examples are listed here

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ayt_api-0.3.0.tar.gz (33.4 kB view details)

Uploaded Source

Built Distribution

ayt_api-0.3.0-py3-none-any.whl (32.5 kB view details)

Uploaded Python 3

File details

Details for the file ayt_api-0.3.0.tar.gz.

File metadata

  • Download URL: ayt_api-0.3.0.tar.gz
  • Upload date:
  • Size: 33.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for ayt_api-0.3.0.tar.gz
Algorithm Hash digest
SHA256 459b99c97c720b2357ccfcadc9d5d9350b710a384f415ba63b726d316691ac39
MD5 e3697119dc773a68a8f70c3cd2df2553
BLAKE2b-256 5135e7826be6a03ad9ac978d765818d0d0891f5435a8b73291eed833673c35aa

See more details on using hashes here.

File details

Details for the file ayt_api-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: ayt_api-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 32.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for ayt_api-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2a4f838d6d9e3e1b65c5b4a4a6893ec01de8b7e724bbdde250231acc4aae2ed2
MD5 e40938063985242f8d2c62f80292f911
BLAKE2b-256 9285b5ed1875c7d3abee34f6a8ef34557195811fe2cfb5b18d24a9f326cd9b23

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page