Twitter API with Python: Part 2 -- Cursor and Pagination

Twitter API with Python: Part 2 -- Cursor and Pagination
In this video, we will continue with our use of the Tweepy Python module and the code that we wrote from Part 1 of this series:

The goal of this video will be to understand how Tweepy handles pagination, that is, how can we use Tweepy to comb over the various pages of tweets? We will see how to accomplish this by making use of Tweepy's Cursor module. In doing so, we will be able to directly access tweets, followers, and other information directly from our own timeline. We will also continue to improve the code that we wrote from Part 1

Relevant Links:

Part 1:  https://www.youtube.com/watch?v=wlnx-7cm4Gg
Part 2: https://www.youtube.com/watch?v=rhBZqEWsZU4
Part 3: https://www.youtube.com/watch?v=WX0MDddgpA4
Part 4: https://www.youtube.com/watch?v=w9tAoscq3C4
Part 5: https://www.youtube.com/watch?v=pdnTPUFF4gA

Tweepy Website:

Cursor Docs:

API Reference:

GitHub Code for this Video:

My Website:

This video is brought to you by DevMountain, a coding boot camp that offers in-person and online courses in a variety of subjects including web development, iOS development, user experience design, software quality assurance, and salesforce development. DevMountain also includes housing for full-time students.

For more information: 

RRelated Posts

REST API concepts and examples

This video introduces the viewer to some API concepts by making example calls to Facebook's Graph API, Google Maps' API, Instagram's Media Search API, and Twitter's Status Update API. /**********


  • Layla Zhang
    Vinnie! Could you please do a series on Kafka with Python (potentially using this twitter streaming API as an example)? You are so good at explaining things and I'm having a hard time finding quality content on this particular subject on YouTube.
  • Ahmed Altarawenh
    can i get the user_id for every single tweet ? and the followers for this user ?
  • entelechy
    Great tutorial series! What about dealing with emojis and other unicode errors? Because the Status object isn't just a straight dictionary it's been hard to find a general solution for any Status as there are unicode errors popping up all throughout the object.
  • alawi0juventus
    great work bro, thank you for the time you put to make those videos.
  • Harrel Blatt
    This returns a list. I was hoping the returned object is son then we can access it with keys?
  • gonatrollya
    Hey man are you going to make more of these
  • Dividend Portfolio
    The git link in the description is error 404
  • Mark Wagoner
    When will the next video be available for how to sort through the tweet and clean it up? Great video. Very helpful
  • SGE Kids
    Not that I quite understand what they are doing, but I've read that Twitter is taking away cursor/page type functions with their updated API and the paid tiers. I've searched online for details about how this will affect Tweepy, but since the change hasn't officially happened yet, I don't know if anyone has addressed it.

    So, I guess my question is this: how will Tweepy be affected once the deprecations go through (in August)?

    And a follow up question: I use Tweepy as a Send Tweets bot (which I think I will be able to continue post change), but I also use it to get users, filter them, and then follow/unfollow/retweet and so forth … how will I perform these actions once certain functions are deprecated?

    Sorry if my questions are confusing.
  • Marco Marine
    So amazing tutorial, really you went through the API and explained everything in very concise and helpful way.
    if status==420

  • Ryan
    Awesome tutorial! How would you live stream a specific user's tweets rather than pulling in recent tweets? Thanks! :)
  • abhijit singh
    hey thanks for the video, can you please tell how to dump this in MySQL database?
  • Pablo Viana
    Excellent video!