How can I get a count of specific topic?


#1

Hi, I am a newbie in Twitter APIs. Now I get a project that I need to get a count number of specific topic, such as comment count or re-twitter count. Somebody can share with me solutions? Really appreciate for that.


#2

Hey, welcome! What do you mean by “specific topic”?


#3

I mean, how can I get the amount number of comments or re-twitters for one topic (such as #2015NewYear). I need this number to analyze which topic is hot topic. :slight_smile:


#4

This is not possible. If you want to get the Hot Topics, you can use the trend REST API Endpoint:

  • /trends/closest: Get nearby locations where Twitter has trending topic informations for
  • /trends/available: Get all locations where Twitter has trending topic informations for
  • /trends/place: Get the 10 hottest trending topics for a location (see the endpoints above for how to get a location id)

#5

You might misunderstand me, I just want to pay attention to my own topic.

As your mean, the following thing is impossible?

If I initiated two topics(#2015NewYear and #2015Xmas), I want to set up a web program to count their comments or re-twitter amount and evaluate which ones is more popular.

Or, do you have another way to resolve this situation.


#6

There is no straightforward way to do this.
The best way currently is to use the streaming API:

You can use the statuses/filter endpoint to set a filter for your topics (we call these “hashtags”) using the track parameter (for your example you would need to set it to track=%232015NewYear%2C%232015Xmax) and count the results, inspecting the entities hashtag object to see to which keyword it matched and increment a counter.


#7

OK, Thanks a lot.