Home

Awesome

Why twitterati

We like to uncomplicate things, and wrappers (except when they actually wrap :gift ) do exactly that.

This package serves as a wrapper for Twitter API V2 Early Access, for more info: https://developer.twitter.com/en/docs/twitter-api/early-access.

What is new in Twitter API V2?

Functions supported by twitterati 0.0.3:

Before you get started:

Be sure to familiarize yourself with the terms and conditions of the Twitter Developer API: https://developer.twitter.com/en/developer-terms/agreement-and-policy.

Also, take note of the restricted use cases, detailed here: https://developer.twitter.com/en/developer-terms/more-on-restricted-use-cases

You will need to register an account and an application to collect your Bearer token: https://developer.twitter.com/en/apply-for-access

Take note of the rate limits: the Standard Track limits the number of tweets you can collect to 500,000 per month.

You must keep all API keys or other access credentials private.

Installation

pip3 install twitterati

Credentials

Once allocated, you can export your bearer token to your environment:

export BEARER_TOKEN='XXXXXXXXXXX'

Getting a user's metadata


from twitterati import lookups

user = lookups.get_user_profile(user_id)

Getting all the tweets that contain a search term over the past 7 days


from twitterati import lookups

tweets = lookups.recent_search_lookup('python', max_count = 1000)

Count the number of tweets that contain a search term over the past 7 days


from twitterati import lookups

counts = lookups.count_recent_tweets('python')

Getting a conversation by conversation_id:


from twitterati import lookups

convo = lookups.conversation_lookup(conversation_id)