13.9 Introduction to Tweepy Cursors: Getting an Account’s Followers and Friends

When invoking Twitter API methods, you often receive as results collections of objects, such as tweets in your Twitter timeline, tweets in another account’s timeline or lists of tweets that match specified search criteria. A timeline consists of tweets sent by that user and by that user’s friends—that is, other accounts that the user follows.

Each Twitter API method’s documentation discusses the maximum number of items the method can return in one call—this is known as a page of results. When you request more results than a given method can return, Twitter’s JSON responses indicate that there are more pages to get. Tweepy’s Cursor class handles these details for ...

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.