TweetyPy: Python-based CLI client for Twitter | 17 Comments
Posted in Code on 24th March 2007, 2:35 am by Stuart
TweetyPy is now hosted on launchpad.net

Having recently created a Twitter bundle for Textmate I came to the conclusions that using PHP for the command was fairly limiting. Having wanted to take a look at Python for a while I decided this was the ideal opportunity to build something and learn at the same time. The goal was to write a command line Twitter client. I thumbed through Mark Pilgrim’s excellent book;”Dive into Python” on the train home and by the end of the evening I had a basic client up and running complete with nice argument handling using getopt.
This evening I have added support for timelines of “you and your friends”, the “public timeline” and lists of “friends” and “followers”. To make these look nice I utilised a cunning module called TextFormatter written by Hamish Lawson that wraps text into columns so that the output is neat and tidy.
TweetyPy can currently do the following:
- Update your status
- Display the public timeline
- Display the timeline of you and your friends
- Display your followers
- Display your friends
Usage Examples:
- Update your status
python tweetyPy -t 'update' -u blah@blah.com -p password -s "Sitting on the toilet"- Get the timeline of you and your friends
python tweetyPy -t 'friends_timeline' -u blah@blah.com -p password- Show list of followers
python tweetyPy -t 'followers' -u blah@blah.com -p password- Show help
python tweetyPy -h
Note: if you make tweetyPy executable that should do away with the need to call it from Python.
Eventually (time permitting) I will roll TweetyPy into the TextMate bundle and add all of the features that it has into TextMate. This will probably mean I will add a customisable output mode to TweetyPy so that you can view the time-lines in TextMate’s HTML Output window. That should certainly make the bundle a little more interesting than just being able to update your status.
Needless to say this is my first foray into the wonderful world of Python, therefore if you have any comments or suggestions leave a comment below. I’m sure there’s lots of room for improvement.
Releases:
- TweetyPy v0.22
- Fixed removal of relative_created_at from API. Will improve formatting in due course.
- TweetyPy v0.21
- Added reverse of feed, Basic HTML mode. Socket timeout. Better error handling. Other small fixes
- TweetyPy v0.2
- Fixed Usage which indicated wrong file + updated examples
- TweetyPy v0.1
- Initial Release
Todo list
- Improve on the time formatting now that relative_created_at has been removed from the API.
- Add a follow mode like tail -f (Will need to observer headers and only update with new items)
Add html mode – required if I am going use this from TextMate- Better authentication storage (keychain for mac? etc)
Reverse order so that most recent twitter is shown first (makes more sense on the CLI)Added User-Agent

Pingback: Twitter - what do you think? - Page 4 - The Apple Blog Community
Pingback: Twitter Hacks » Blog Archive » Hardcore Geeks: Command Line Twitter
Pingback: links for 2007-04-06 « Breyten’s Dev Blog