{"id":22955263,"url":"https://github.com/happycod3r/youtube-data-api-v3-tools","last_synced_at":"2025-04-16T19:09:03.462Z","repository":{"id":185444367,"uuid":"673552695","full_name":"happycod3r/YouTube-Data-API-v3-Tools","owner":"happycod3r","description":"A comprehensive YouTube Data API v3 wrapper library used to easily integrate YouTube functionality into any project.","archived":false,"fork":false,"pushed_at":"2023-08-11T05:06:52.000Z","size":2207,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-14T16:30:13.224Z","etag":null,"topics":["api-wrapper","concise","module","python-module","python3","wip-do-not-use","wrapper-class","youtube","youtube-api","youtube-data-api","youtube-data-api-v3","youtube-data-api-v3-tools"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/happycod3r.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-01T22:34:14.000Z","updated_at":"2024-10-25T00:20:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"0c34ab1d-1bcd-44e9-9d2f-000ff8b16921","html_url":"https://github.com/happycod3r/YouTube-Data-API-v3-Tools","commit_stats":null,"previous_names":["happycod3r/youtube_api_tools","happycod3r/youtube-data-api-v3-tools"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happycod3r%2FYouTube-Data-API-v3-Tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happycod3r%2FYouTube-Data-API-v3-Tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happycod3r%2FYouTube-Data-API-v3-Tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happycod3r%2FYouTube-Data-API-v3-Tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/happycod3r","download_url":"https://codeload.github.com/happycod3r/YouTube-Data-API-v3-Tools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237676250,"owners_count":19348573,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-wrapper","concise","module","python-module","python3","wip-do-not-use","wrapper-class","youtube","youtube-api","youtube-data-api","youtube-data-api-v3","youtube-data-api-v3-tools"],"created_at":"2024-12-14T16:28:50.376Z","updated_at":"2025-02-07T16:16:56.424Z","avatar_url":"https://github.com/happycod3r.png","language":"Python","readme":"# YouTube Data API v3 Tools Library\n\n![YouTubeDataAPIv3Tools](./docs/youtube_data_api_tools.png)\n\n\u003e The YouTube Data API v3 Tools Library is a concise wrapper around the YouTube API. The `YouTubeDataAPIv3Tools` \n\u003e class and sub-classes contain hundreds of methods to interact with YouTube. These methods cover all \n\u003e categories such as videos, video categories, playlists, playlist items, subscriptions, comments, \n\u003e comment threads, captions, live streaming, channels, thumbnails, watermarks, localizations, activities, \n\u003e search, members, membership levels \u0026 abuse reporting. I made sure to cover all the bases.\n\n## [Setup](#setup)\n        \n### [OAuth 2.0 credentials](#oauth2credentials)\n\nA `client_secret.json` file is needed in order for this class to be functional.\nOr should I say ... classy ....\n\n### [Required Python modules](#required_modules)\n\n- google-auth\n- google-auth-oauthlib\n- google-auth-httplib2\n- google-api-python-client\n      \nKeep in mind that you need to have the proper **OAuth 2.0** authentication set up and the \npermissions to manage a YouTube account. Below is a step-by-step guide on how to\nobtain a ***client_secret.json*** file. \n\n*Please also note that the steps for setting up OAuth 2.0 authentication and using the \nclient_secret.json file might change over time. For the latest and most detailed \ninstructions, you should refer to the official Google API documentation for the YouTube \nAPI and OAuth 2.0 authentication for Python.* [https://developers.google.com/youtube/v3/quickstart/python](https://developers.google.com/youtube/v3/quickstart/python)\n\n1) [Google Cloud Console:](#google-cloud-console)\n\nTo use the ***YouTube API*** or any other Google API, you need to create a project on the \n**Google Cloud Console** and enable the APIs you want to use.\n\n2) [OAuth 2.0 Credentials:](#oauth-2-credentials)\n        \nAfter creating the project and enabling the YouTube API, you need to create OAuth 2.0 \ncredentials. These credentials are used to identify your application and to \nauthenticate and authorize access to the API. The credentials contain a client ID, \nclient secret, and other information.\n                \n3) [Download Client Secret:](#download-client-secret)\n\nOnce you create OAuth 2.0 credentials, you can download the *client_secret.json* file \nfrom the Google Cloud Console. This file contains the client ID and client secret, \nwhich are used in the authentication process.\n            \n4) [Authentication Flow:](#authentication-flow)\n        \nWhen you run your Python application that interacts with the YouTube API, it will \nprompt the user to authenticate their Google account through a web browser (if necessary). \nThe *client_secret.json* file is used during this authentication flow to identify your \napplication and establish a secure connection.\n\n5) [Access Tokens:](#access-tokens)\n\nAfter the user grants permission to your application, the authentication server provides \nyour application with an access token. This access token is used in API requests to \nprove that your application has been granted permission to access the user's resources.\n\n6) [Protecting Client Secret:](#protecting-client-secret) \n            \nThe *client_secret.json* file contains sensitive information (client secret), so it should \nbe kept confidential and not shared or exposed publicly. It is important to store the \nclient_secret.json file securely on the server-side of your application.\n\nWhen you use the Google API Client Library for Python to interact with the YouTube API, you'll \nneed to set up the OAuth 2.0 authentication flow and provide the path to the client_secret.json \nfile in your code to initiate the authentication process.\n\n---\n\n## [Usage](#usage)\n\u003e !!! NOTE: Any sensitive data used in these examples is void or not real !!!\n\n\nFirst import the `youtube_api_tools` module.\n\n```python\nimport youtube_api_tools\n```\n\nNext create a `YouTubeDataAPIv3Tools` object and pass the path to your ***client_secret.json*** file path\nas the first argument to the constructor and a list of scopes that you want to use as the \n2nd argument. Then optionally pass an API developer key as the 3rd argument if you have one.\n\n```python\n_client_secret = \"client_secret_913312345634-hsdfrlsskr1gqsedjdsddnjga57j84s0chml.apps.googleusercontent.com.json\"\n_scopes = [\"https://www.googleapis.com/auth/youtube.readonly\"]\n_dev_key = \"A01ssSpaAWMeM1XsfguYJFxxnDIamdfgh-tLSAs823d\"\n\nyoutube = youtube_api_tools.YouTubeDataAPIv3Tools(\n    _client_secret,\n    _scopes,\n    _dev_key\n)\n```\n\nThe constructor will call the `get_authenticated_service()` method which will set up the OAuth 2.0 \nflow using your ***client_secret.json*** file to authenticate the user and will store the \nauthorization token in a ***token.pickle*** file. The actual service is wrapped in a method called `_get_authenticated_service()` and dependency injected. Pretty much all of the YouTubeDataAPIv3Tools class \nmethods and subclass methods rely on this authentication, so the service returned from `_get_authenticated_service` \nwill be stored in a class variable called `self.service`. Upon instanciation of any subclass of `YouTubeDataAPIv3Tools` a reference to the YouTubeDataAPIv3Tools class will be passes. This we way have a reference to the service stored in `self.service` in all sub classes and methods. Here is an example:\n\n```python\ntube = YouTubeDataAPIv3Tools(\u003cyour json\u003e, \u003cscopes\u003e, \u003cdev key\u003e)\n\n# pass 'tube' as the first argument to the subclasses upon\n# instanciaution.\nchannel = tube.Channel(tube) \nplaylist = tube.Playlist(tube)\nitem = tube.PlaylistItem(tube)\nvideo = tube.Video(tube)\n\ncnn_channel_id = channel.get_id(False, \"CNN\")\ncnn_playlist_id = playlist.get_id(\"US News\", cnn_channel_id)\nusnews_playlist_videos = playlist.get_playlist_items(cnn_playlist_id)\n\n# Like and unlike a playlists videos based on filters.\nfor playlist_video in cnn_playlist_videos:\n    video_id = playlist_video[\"id\"]\n    video_title = playlist_video[\"snippet\"][\"title\"]\n    if video_title == \"somethin somethin\":\n        video.like(video_id)\n    else:\n        video.unlike(video_id)\n    \n```\n\nIf no calls to the API are made after a few minutes the user will have to reauthenticate and\ngrant the app permissions again in the browser. The ***token.pickle*** file will no\nlonger work until this is done.\n\n\u003e Note: The `token.pickle` file is important because without it the reauthentication process has to \nbe done with every individual call to the YouTube Data API.\n\nOnce you have created the `YouTubeDataAPIv3Tools` object. The following subclasses are available:\n\n- YouTubeDataAPIv3Tools.Channel\n- YouTubeDataAPIv3Tools.ChannelSection\n- YouTubeDataAPIv3Tools.Playlist\n- YouTubeDataAPIv3Tools.PlaylistItem\n- YouTubeDataAPIv3Tools.Video\n- YouTubeDataAPIv3Tools.VideoCategories\n- YouTubeDataAPIv3Tools.Captions\n- YouTubeDataAPIv3Tools.Subscriptions\n- YouTubeDataAPIv3Tools.Members\n- YouTubeDataAPIv3Tools.MembershipLevel\n- YouTubeDataAPIv3Tools.Comment\n- YouTubeDataAPIv3Tools.CommentThread\n- YouTubeDataAPIv3Tools.Thumbnail\n- YouTubeDataAPIv3Tools.WaterMark\n- YouTubeDataAPIv3Tools.Activity\n- YouTubeDataAPIv3Tools.Search\n- YouTubeDataAPIv3Tools.LiveBroadcasts\n- YouTubeDataAPIv3Tools.Localization\n- YouTubeDataAPIv3Tools.AbuseReport\n- YouTubeDataAPIv3Tools.AbuseReport.VideoAbuseReportReason\n\nThese classes wrap each resource type and contain a ton of methods to interact \nwith them in various ways.\n\n---\n\n### Get your channel ID:\n\n```python\ntube = youtube_api_tools.YouTubeDataAPIv3Tools(arg1, arg2, ...)\nchannel = tube.Channel(tube) \n```\n\n### Get a playlist ID:\n\n```python\nplaylist_id = youtube.get_playlist_id()\n```\n\n### Get a video ID:\n\n\nThe rest of the documentation will be finished soon.\n\n## [Resources](#resources)\n\nFor information on common API errors check out [API_ERRORS.md](./docs/API_ERRORS.md) or \nthe official documentation here: [https://developers.google.com/youtube/v3/docs/errors](https://developers.google.com/youtube/v3/docs/errors)\n\nFor information on the resources that these class methods act on check\nout [API_RESOURCES.md](./docs/API_RESOURCES.md)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhappycod3r%2Fyoutube-data-api-v3-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhappycod3r%2Fyoutube-data-api-v3-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhappycod3r%2Fyoutube-data-api-v3-tools/lists"}