Welcome to Simple YouTube API’s documentation!
Simple YouTube API is a YouTube API wrapper that supports uploading, fetching and updating videos and bunch of other basic YouTube features.
Guide
Download and Installation
Installation
Simple YouTube API needs API keys from Google in order to be able to make queries to YouTube.
Installation by hand: you can download the source files from PyPi or Github:
$ (sudo) python setup.py install
Installation with pip: make sure that you have pip
installed, type this in a terminal:
$ (sudo) pip install simple-youtube-api
Generating YouTube API Keys
Log into https://console.cloud.google.com
Create a new Project
Search for “YouTube Data API V3”
Click Credentials
Click Create Credentials
Select that you will call API from “Web Server”
Select “Public Data” if you want to not get private data and “User Data” if you do
Download or copy your API key from the Credentials tab
Getting started with Simple YouTube API
These pages explain everything you need to know to start using Simple YouTube API.
Example Scripts
Here are a few example scripts to get you started.
Upload a YouTube Video
from simple_youtube_api.Channel import Channel
from simple_youtube_api.LocalVideo import LocalVideo
# loggin into the channel
channel = Channel()
channel.login("client_secret.json", "credentials.storage")
# setting up the video that is going to be uploaded
video = LocalVideo(file_path="test_vid.mp4")
# setting snippet
video.set_title("My Title")
video.set_description("This is a description")
video.set_tags(["this", "tag"])
video.set_category("gaming")
video.set_default_language("en-US")
# setting status
video.set_embeddable(True)
video.set_license("creativeCommon")
video.set_privacy_status("private")
video.set_public_stats_viewable(True)
# setting thumbnail
#video.set_thumbnail_path("test_thumb.png")
video.set_playlist("PLDjcYN-DQyqTeSzCg-54m4stTVyQaJrGi")
# uploading video and printing the results
video = channel.upload_video(video)
print(video.id)
print(video)
# liking video
video.like()
YouTube Search
from simple_youtube_api.YouTube import YouTube
with open("developer_key", "r") as myfile:
data = myfile.read().replace("\n", "")
developer_key = data
# logging into youtube
youtube = YouTube()
youtube.login(developer_key)
# searching videos with the term
videos = youtube.search("Your Search Term")
# printing results
for video in videos:
print(video)
# search a specific video
video = youtube.search_by_video_id("Ks-_Mh1QhMc")
print(video)
Update a YouTube Video
from simple_youtube_api.YouTubeVideo import YouTubeVideo
from simple_youtube_api.Channel import Channel
from simple_youtube_api.YouTube import YouTube
with open("developer_key", "r") as myfile:
data = myfile.read().replace("\n", "")
developer_key = data
youtube = YouTube()
youtube.login(developer_key)
video = youtube.search_by_video_id("aSw9blXxNJY")
channel = Channel()
channel.login("client_secret.json", "credentials.storage")
video.update(channel, title="hehe")
Fetch My Uploads
from simple_youtube_api.Channel import Channel
from simple_youtube_api.YouTubeVideo import YouTubeVideo
channel = Channel()
channel.login("client_secret.json", "credentials.storage")
videos = channel.fetch_uploads()
for video in videos:
print(video)
Fetch available categories in YouTube
from simple_youtube_api.YouTube import YouTube
with open("developer_key", "r") as myfile:
data = myfile.read().replace("\n", "")
developer_key = data
youtube = YouTube()
youtube.login(developer_key)
youtube.fetch_categories()
Reference Manual
Reference manual for Simple YouTube API
LICENSE
MIT License
Copyright (c) 2019-2020 Jonne Kaunisto
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Contribute !
Simple YouTube API is an open source Python YouTube API wrapper originally written by Jonne Kaunisto.