Skip to content
Minimal python wrapper for Twitter's REST and Streaming APIs
Branch: master
Clone or download



BADGE_VERSION Join the chat at

TwitterAPI is a Python package for accessing Twitter's REST APIs and Streaming APIs. It supports OAuth 1.0 and OAuth 2.0 authentication. And, it works with the latest Python versions in both 2.x and 3.x branches.

REST APIs that are supported are: Public API, Collections API, Curator API, Ads API, Webhook API, Premium Search API.


From the command line:

pip install TwitterAPI


Some Code...

[See TwitterAPI/examples for working examples.]

First, authenticate with your application credentials:

from TwitterAPI import TwitterAPI
api = TwitterAPI(consumer_key, consumer_secret, access_token_key, access_token_secret)

Tweet something:

r = api.request('statuses/update', {'status':'This is a tweet!'})

Get tweet by its id:

r = api.request('statuses/show/:%d' % 210462857140252672)

Get some tweets:

r = api.request('search/tweets', {'q':'pizza'})
for item in r:

Stream tweets from New York City:

r = api.request('statuses/filter', {'locations':'-74,40,-73,41'})
for item in r:

Notice that request() works with all endpoints found in either the REST APIs or the Streaming APIs. Usually request() takes two arguments: a Twitter endpoint and a dictionary of endpoint parameters. The above examples use get_iterator() to consume each tweet object. The iterator knows how to iterate results returned from either the REST APIs or the Streaming APIs.

You also have access to the response object returned by request(). From a response object r you can get the raw response with r.text and the HTTP status code with r.status_code. See the requests library documentation for more details.

Extra Goodies

Command-Line Utility (examples/cli)

You can’t perform that action at this time.