Simple Twitter Streaming client for Tornado
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 16 commits ahead of joshmarshall:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README.md
requirements.txt
setup.py
tests.py
tweetstream.py

README.md

The TweetStream class is just a simple HTTP client for handling the twitter streaming API.

Usage is pretty simple:

import tweetstream

def callback(message):
    # this will be called every message
    print message

configuration = {
    "twitter_consumer_key": "key",
    "twitter_consumer_secret": "secret",
    "twitter_access_token": "token",
    "twitter_access_token_secret": "secret",
}

stream = tweetstream.TweetStream(configuration)
stream.fetch("/1.1/statuses/filter.json?track=foobar", callback=callback)

# if you aren't on a running ioloop...
from tornado.ioloop import IOLoop
IOLoop.instance().start()

The constructor takes two optional arguments, ioloop and clean. The ioloop argument just lets you specify a specific loop to run on, and clean is just a boolean (False by default) that will strip out basic data from the twitter message payload.