Very simple interface for Youtube API v3 to fetch public video data.
No need for OAuth2.0 or many dependencies (needs only requests
).
Having some auth and quota issues with the official python api googleapis/google-api-python-client and just for fun, I ended up coding this easy api for my simple needs. used in MrKrautee/video-gatherer.
- fetches public youtube video data
- implements following endpoints:
- option to cache requests for development ('save quota')
- option to fetch all search results at once (no pagination)
- option to include detailed video informations, 'contentDetails' (uses more quota)
from video_finder import video_finder
finder = video_finder.YoutubeFinder("my-api-key")
videos = finder.search_videos(search_query="summon python", content_details=True)
for v in videos:
print(f"{v.title} - {v.duration}")
Read the code for more details:
YoutubeFinder
will return those types in a list:
YoutubeAPI
will return the raw response from the youtube rest api.
As I mentioned, read the sources for further information: video_finder/video_finder.py
for all searches:
supported ? | param name |
---|---|
x | part(required) |
x | channelId |
x | channelType |
x | maxResults |
x | order |
x | pageToken |
x | published_after |
x | published_befor |
x | q |
x | type |
regionCode | |
x | relevanceLanguage |
safeSearch | |
location | |
locationRadius |
only for video searches:
supported ? | param name |
---|---|
x | eventType |
x | videoCaption |
x | videoDuration |
x | videoEmbeddable |
videoLicense | |
videoSyndicated | |
videoType | |
x | videoDefinition |
videoDimension | |
x | relatedToVideoId |
videoCategoryId |
$ export YOUTUBE_API_KEY=Your-Api-Key-abcdefg
$ python -m pytest tests --verbose
- YouTube Data API v3 Documentation
- Developer Console to get yout API key