ta.TwitterDB.searchPremiumAPI¶
-
TwitterDB.searchPremiumAPI(twitter_bearer, api_name, dev_environment, query, date_start, date_end, next_token=None, max_count='100')[source]¶ Send requests to the Premium search API and save data into MongoDB
- Parameters
twitter_bearer – bearer authentication token created from the consumer_key and consumer_secret
api_name – the options are either 30day or FullArchive
dev_environment – the name of the environment created on the Twitter’s developer account
query – the query that will be used to filter the tweets
date_start – the start date that will be used to filter the tweets.
date_end – the end date that will be used to filter the tweets.
next_token – then token that points to the previous search done with the same query.
max_count – the number of tweets to be returned at a time
- Returns
response – the response received from Twitter, which will contain either the tweets retrieved from the search, or the error message if any
next_token – token value that can be used for the next request, that way it is possible to avoid searches for the same records
Examples
>>> # send request to premium API >>> response, next_token = myAnalysisObj.searchPremiumAPI( >>> twitter_bearer = '[bearer]', >>> api_name = '30day', >>> dev_environment = 'myDevEnv.json', >>> query = '(coronavirus OR COVID19) lang:en', >>> date_start = '202002150000', >>> date_end = '202002160000', >>> next_token = None, >>> max_count = '100' >>> )