skip to navigation
skip to content

birdfeeder 0.0.4

A newslynx-opinionated wrapper around twython

Latest Version: 0.1.9

birdfeeder ====== Feed on tweets


pip install birdfeeder


Requires nose



birdfeeder simplifies twython by taking care of alot the common problems in working with the Twitter API, including:

  • pagination
  • rate limiting
  • url unshortening
  • error handling

Thus far, we’ve implemented 5 methods: connect, search, list_timeline, user_timeline, and user_stats (a custom method):


If you have TWT_API_KEY, TWT_API_SECRET, TWT_ACCESS_TOKEN, and TWT_ACCESS_SECRET set as environmental variables, you can use all the methods without explicitly connecting. However, if you want to explicitly connect beforehand, you can also pass in a connection as conn to any method:

from birdfeeder import connect, search

conn = connect()
for t in search(q="hello world", conn=conn):
  print t

In addition, you can also pass in an authenticated user’s token with access_token:

from birdfeeder import connect, search

for t in search(q="hello world", access_token="authenticed_users_token"):
  print t

List Timeline

from birdfeeder import list_timeline

tweets = list_timeline(owner_screen_name = 'cspan', slug = 'members-of-congress', count=100)
for t in tweets:
  print t

User Timeline

from birdfeeder import user_timeline

tweets = user_timeline(screen_name = 'newslynx')
for t in tweets:
  print t

User Stats

This returns a dictionary of stats about a user, with the time it ran. It’s intended for creating a time series of a user’s metadata:

from birdfeeder import user_stats
stats = user_stats(screen_name = "newslynx")
print stats

Custom Options

We’ve added some custom options for each method, they are as follows:

  • throttle - the time in seconds to wait between each request (only relevant when paginate = True)
  • max_requests - the maximum number of requests to make (only relevant when paginate = True)
  • wait - the default number of seconds to wait after an error
  • backoff - the factor to multiply wait by after each error
  • timeout - the time in seconds at which point we should abandon an error prone request. Here, birdfeeder will log a warning, but will otherwise fail silently.

Here are the default arguments for all methods:

default_kws = {
  'paginate' : False,
  'max_id': None,
  'throttle' : 15,
  'count' : 200,
  'max_requests' : None,
  'wait': 1,
  'backoff': 2,
  'timeout': 30


Finally, we’ve included a simple streaming API client (from here). With this, you can pass in three functions on initialization: a parsing function, a storage function, and an error function, ie:

from birdfeeder import Stream

def parse(data):
  return data['text']

def store(data):
  print data

def error(status_code, data):

s = Stream(parse=parse, store=store, error=error)


To write this library, I heavily referenced Jeremy Singer-Vine’s excellent `twick <>`__.

File Type Py Version Uploaded on Size
birdfeeder-0.0.4.macosx-10.9-intel.exe (md5) MS Windows installer any 2014-06-12 72KB
birdfeeder-0.0.4.tar.gz (md5) Source 2014-06-12 6KB