I'm new to Python and need some help. I'm trying to search for historical tweets from 2014 to 2018 from specific Twitter users with specific keywords in a research project and have a few questions for my code.
#Endpoint from Twitter Developer
endpoint = 'https://api.twitter.com/1.1/tweets/search/30day/dev.json'
#All keywords
query = 'xxxx' or 'yyyy'
#Search code
search = tweepy.Cursor(api.search, q = query, "from:TwitterUser -filter:retweets", lang = 'en').items()
for item in search:
print (item.text)
And as an additional question not related to my code, is it possible to search for retweets and likes by specific users on certain tweets? Lets say I'm searching for tweets from user1, can I then see how many times user2, user3 and user4 have retweeted and liked user1's tweets?
Thanks for any help!
Cheers
I don't believe that tweepy currently provides support for the premium search endpoints (additionally, I see that your code is hitting a 30 day endpoint, when for your use case you would need to access the full archive search endpoint).
For premium search I would recommend that you look at either TwitterAPI, or the search-tweets-python library that we (Twitter) provide. In the case of the latter, it also supports the counts endpoint, but be aware that these are only available in the paid tier, not the free sandbox. Also, note that the search syntax on the premium search API is different to standard search. Check the documentation.
On your last question unrelated to code - no, there's no API that would enable you to find that information.