I am attempting to make a Discord bot that will post the top tweet of a hashtag when requested however I cannot figure out how to do this. I cant find anything for searching tweets of a hashtag in the Twitter API. How can I achieve this? Alternate solutions are welcome but I need it to be a Discord bot. Thanks!
Question posted in Twitter API
The official Twitter API documentation can be found here.
The official Twitter API documentation can be found here.
2
Answers
Judging by the this api reference they have a custom query thing going on. I’m sure you should be able to use their query options to get the data you want
Did you look at the search API documentation? There’s an example for a hashtag right there:
You will need to do some work in your code to decide what constitutes "the top tweet" – do you mean the most recent Tweet, the Tweet with most likes, the most retweets, etc – you will have to check the metrics on the Tweet objects to decide which Tweet is "top" in your definition, there’s nothing built-in to the API that returns just the "top" Tweet, unless you just want the most recent result.