Skip to content

No-boilerplate, async and typed YouTube Analytics access. πŸ˜‹

License

Notifications You must be signed in to change notification settings

dunkyl/SlyYTAAPI-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Aug 13, 2024
52b6643 Β· Aug 13, 2024

History

17 Commits
Aug 13, 2024
Aug 13, 2024
Aug 2, 2023
Mar 1, 2023
Mar 1, 2023
Nov 25, 2021
Mar 1, 2023
Mar 1, 2023

Repository files navigation

sly logo Sly YTAAPI for Python

🐍 For Python 3.10+

No boilerplate, async and typed Youtube Analytics API access. πŸ˜‹

pip install slyytaapi

This library does not have full coverage. Currently, the following topics are supported:

  • Targeted queries for channels and videos

You can directly grant user tokens using the command line, covering the whole OAuth 2 grant process.


Example usage:

import asyncio
from datetime import date
from SlyYTAAPI import *

async def main():

    auth = OAuth2('test/app.json', 'test/user.json')
    analytics = YouTubeAnalytics('UCxATMl-Cv8BEF0FtZMRvRgA', auth)

    result = await analytics.query(
        since=date(2020, 1, 1),
        end_date=date(2021, 1, 1),
        metrics=Metrics.SubsGained+Metrics.SubsLost+Metrics.WatchTime,
        dims=Dimensions.Day
        )

    result.saveCSV('test/test.csv')

asyncio.run(main())

Example CLI usage for getting authorized:

# WINDOWS
py -m SlyYTAAPI grant
# MacOS or Linux
python3 -m SlyYTAAPI grant

Granting credentials requires a Google Cloud Console account and JSON file. Please see https://docs.dunkyl.net/SlyAPI-Python/tutorial/oauth2.html for more information.

About

No-boilerplate, async and typed YouTube Analytics access. πŸ˜‹

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages