class documentation

Retrieve data from the Twitter REST API.

Method __init__ Undocumented
Method expand_tweetids Given a file object containing a list of Tweet IDs, fetch the corresponding full Tweets from the Twitter API.
Method register Register a method for handling Tweets.
Method search_tweets Call the REST API 'search/tweets' endpoint with some plausible defaults. See the Twitter search documentation for more information about admissible search parameters.
Method user_info_from_id Convert a list of userIDs into a variety of information about the users.
Method user_tweets Return a collection of the most recent Tweets posted by the user
Instance Variable do_continue Undocumented
Instance Variable handler Undocumented
Method _search_tweets Assumes that the handler has been informed. Fetches Tweets from search_tweets generator output and passses them to handler
def __init__(self, app_key, app_secret, oauth_token, oauth_token_secret): (source)

Undocumented

def expand_tweetids(self, ids_f, verbose=True): (source)

Given a file object containing a list of Tweet IDs, fetch the corresponding full Tweets from the Twitter API.

The API call statuses/lookup will fail to retrieve a Tweet if the user has deleted it.

This call to the Twitter API is rate-limited. See <https://dev.twitter.com/rest/reference/get/statuses/lookup> for details.

Parameters
ids_finput file object consisting of Tweet IDs, one to a line
verboseUndocumented
Returns
iterable of Tweet objects in JSON format
def register(self, handler): (source)

Register a method for handling Tweets.

Parameters
handlerUndocumented
TweetHandlerI handlermethod for viewing or writing Tweets to a file.
def search_tweets(self, keywords, limit=100, lang='en', max_id=None, retries_after_twython_exception=0): (source)

Call the REST API 'search/tweets' endpoint with some plausible defaults. See the Twitter search documentation for more information about admissible search parameters.

Parameters
keywordsUndocumented
limitUndocumented
langUndocumented
max_idUndocumented
retries_after_twython_exceptionUndocumented
str keywordsA list of query terms to search for, written as a comma-separated string
int limitNumber of Tweets to process
str langlanguage
int max_idid of the last tweet fetched
int retries_after_twython_exceptionnumber of retries when searching Tweets before raising an exception
Returns
python generatorUndocumented
def user_info_from_id(self, userids): (source)

Convert a list of userIDs into a variety of information about the users.

See <https://dev.twitter.com/rest/reference/get/users/show>.

Parameters
useridsUndocumented
list useridsA list of integer strings corresponding to Twitter userIDs
Returns
list(json)Undocumented
def user_tweets(self, screen_name, limit, include_rts='false'): (source)

Return a collection of the most recent Tweets posted by the user

Parameters
screen_nameUndocumented
limitUndocumented
include_rtsUndocumented
str userThe user's screen name; the initial '@' symbol should be omitted
int limitThe number of Tweets to recover; 200 is the maximum allowed
str include_rtsWhether to include statuses which have been retweeted by the user; possible values are 'true' and 'false'
do_continue: bool = (source)

Undocumented

Undocumented

def _search_tweets(self, keywords, limit=100, lang='en'): (source)

Assumes that the handler has been informed. Fetches Tweets from search_tweets generator output and passses them to handler

Parameters
keywordsUndocumented
limitUndocumented
langUndocumented
str keywordsA list of query terms to search for, written as a comma-separated string.
int limitNumber of Tweets to process
str langlanguage