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: 

Do you like the development environment I'm using in this video? It's a customized version of vim that's enhanced for Python development. If you want to see how I set up my vim, I have a series on this here:

If you've found this video helpful and want to stay up-to-date with the latest videos posted on this channel, please subscribe:

RRelated Posts

What is API ?

http://www.LearnCodeOnline.in in this video we will talk about what is API or also known as application programming interface fb: https://www.facebook.com/HiteshChoudharyPage homepage:

System Design: URL Shortener -- Introduction

This series of videos will focus on the category of "system design". You may encounter these types of interviews for software engineering or programming positions. The purpose of these interviews is


  • 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.
  • Jaymen Luther
    Awesome video, pretty new to code and for some reason the if __name__... statement causes my output to return 0. If I take it away the stream works. Any idea why?
  • DJKH Music
    I am happy to see you are familiar with Harris and Hitchens.
  • Foad S Farimani
    Too many classes! Great job. But this is rather Java not Python!
  • yaojun yan
    Hi, I love your instruction. It is so clear and easy to follow.
    However, I got an error that says "'ascii' codec can't encode character '\u2026' in position 690: ordinal not in range(128)," I don't know what this entails and what I did wrong. If you can help, thanks!
  • frank west
    how can i make it send to a file now that we have taken that code out of main?
  • Otto Sperling
    Great job on the videos, man.
    You've just scored a new happy subscriber.
  • François Viard
    I just watched your two first videos about tweepy aaaand... Well, you got a new suscriber ! Very good content and very clear :)
  • 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!