13.11 Spotting Trends: Twitter Trends API
If a topic “goes viral,” you could have thousands or even millions of people tweeting about it at once. Twitter refers to these as trending topics and maintains lists of the trending topics worldwide. Via the Twitter Trends API, you can get lists of locations with trending topics and lists of the top 50 trending topics for each location.
13.11.1 Places with Trending Topics
The Tweepy API
’s trends_available
method calls the Twitter API’s trends/available
19 method to get a list of all locations for which Twitter has trending topics. Method trends_available
returns a list of dictionaries representing these locations. When we executed this code, there were 467 locations with trending topics:
Get Intro to Python for Computer Science and Data Science: Learning to Program with AI, Big Data and The Cloud now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.