skip to Main Content

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!

2

Answers


  1. 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

    Login or Signup to reply.
  2. Did you look at the search API documentation? There’s an example for a hashtag right there:

    Standalone operators can be used alone or together with any other
    operators (including those that require conjunction).

    For example, the following query will work because it uses the
    #hashtag operator, which is standalone:

    #twitterapiv2

    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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search