Twitter fetch!

Receive twitter username, fetch most recent entries in feed, and display them on the command line.    #twitter #client #python #tweepy    [Source code]

So, remember how I use to complain about the Twitter web client requiring you login, even to just browse the someone’s feed?1 Ya, so I wrote a little python client to fix that… Besides Python, its only other requirement is the tweepy library. (And that you have the Twitter API enabled for your account. I can’t really help you with that, but Google is your friend.)

Usage is as simple as: fill the variables api_key, api_secrets, access_token, access_secret and bearer_token with the values for your account, and then just do:

$ python scriptname.py <twitter_username>

By default the latest 10 entries will be shown; you can change that by passing the number of entries you want after the username. Caveat emptor: Twitter only allows for retrieval of tweets done on the last 7 days! As I my update frequency is likely smaller than that, it is likely that using Twitter’s Web Client (i.e., the website) is still necessary…

July 21, 2022.

* * *

[Update] August 2, 2022. An uncaught exception emerged when user had no tweets on the last 7 days. It has now been properly caught.


  1. Said rant can be read here. The follow up is here.↩︎