Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get Top 100 Games by Number of Viewers Twitch
# Getting data for Top 100 Games by number of viewers
# Default response is for 20 games so you will have to set the parameter 'first to 100'
headers = {
'Authorization' : 'Bearer '+str(access_token),
games_response = requests.get('', headers=headers)
# The response will be a JSON which will include the response data and the pagination cursor
# We need to extract the data from the JSON and convert it into a pandas dataframe
games_response_json = json.loads(games_response.text)
topgames_data = games_response_json['data']
# Converting to a pandas dataframe
topgames_df = pd.DataFrame.from_dict(json_normalize(topgames_data), orient='columns')
# See the first few lines. The response includes id, name, and box art url for the game
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment