I try to get youtube trending by country, based on youtube search API, I can set chart to 'mostPopular' which was supposed to return the trending video details, but it didn't work, and returned an error
from googleapiclient.discovery import build
DEVELOPER_KEY = "XXXXXXXXX"
YOUTUBE_API_SERVICE_NAME = "youtube"
YOUTUBE_API_VERSION = "v3"
def youtube_search(max_results=5, order="relevance", token=None, location=None, location_radius=None,
regionCode=None):
youtube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION, developerKey=DEVELOPER_KEY)
search_response = youtube.search().list(
type="video",
pageToken=token,
order=order,
part="id,snippet", # Part signifies the different types of data you want
chart="mostPopular",
maxResults=max_results,
location=location,
locationRadius=location_radius,
regionCode = regionCode,
).execute()
print(search_response)
youtube_search(regionCode='IE')
Can anyone help?
chart is a parameter on the Videos resource, it is not available on the Search resource.