Categories
Python

Twitter Streaming API with Python

Hasin Vai has a good post about collecting tweets in real time with php. Here’s the post: http://hasin.wordpress.com/2009/06/20/collecting-data-from-streaming-api-in-twitter/ 🙂 If you are a php developer look into there.

Well, I am going to cover Python for the Twitter streaming API. You need the “tweetstream” python module which depends on the “anyjson” module. Please make sure you have these modules installed before you proceed.

Download Links: anyjson | tweetstream

To install these packages, use the built in setup.py of the individual packages :

In my case, I didn’t have the “setuptools” python module installed with my default python installation. So I had to install it to get the setup.py work:

I love the magic of debian packages 🙂

Now, you can install the modules and dive into our example:

That’s it! In real, you get the stream dictionary which you can use to manipulate the tweets.

The “tweetstream” module also lets you access the Track and Follow APIs in a superb fashion!

I love Twitter, I love Python! 🙂

9 replies on “Twitter Streaming API with Python”

Hi that is a genuinely interesting view, It does give one food for thought, I am very delighted I stumbled on your blog, i was using Stumbleupon at the time, in any case i don?t want to ramble on too much, but i would like to say that I will be back when I have a little time to read your blog more thoroughly, Once again thanks a lot for the blog post and please do keep up the right work,

Having setuptools installed, you could just use
sudo easy_install tweetstream
and get tweetstream and all it’s dependencies installed automatically (just like using Apt-get or Yum).

Comments are closed.