tweety.api.search() retrevieing fewer results compared to rtweet::search_tweets()? #1435
-
Hi all, Trying to get off the ground with the Twitter API and doing some sanity checks for basic API calls across R, Python, and command line. I'm using # Source: https://towardsdatascience.com/tweepy-for-beginners-24baf21f2c25
import tweepy
twitter_keys = {
'consumer_key': 'x',
'consumer_secret': 'x',
'access_token_key': 'x',
'access_token_secret': 'x'
}
# Setup access to API
auth = tweepy.OAuthHandler(twitter_keys['consumer_key'], twitter_keys['consumer_secret'])
auth.set_access_token(twitter_keys['access_token_key'], twitter_keys['access_token_secret'])
# Setup auth in API
api = tweepy.API(auth)
# Get all tweets in 2 mile radius of College Park, MD
public_tweets = api.search(geocode="38.987202,-76.945999,2mi", count=1000) However, when I try to run an equivalent command in R I get around 3737 tweets: rt2mi <- search_tweets(
geocode = "38.987202,-76.945999,2mi", # do not include spaces
retryonratelimit = TRUE,
n = 10000
) Any reason for this discrepancy? Perhaps I'm missing something about I am using the same API keys and access tokens. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
API.search
makes a single call to the standard search API, for which thecount
parameter has a maximum of 100.See https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/api-reference/get-search-tweets.
For paginated results, you should use a
Cursor
object. See https://tweepy.readthedocs.io/en/latest/cursor_tutorial.html.