Jonathan
Jonathan

Reputation: 32868

Does the Twitter API allow filtering by username AND hashtag?

Can I get all the tweets of a particular user, in which a particular hashtag is used?

I could just get the past 100 tweets then filter them on my end, but it would be much more convenient if Twitter could do the filtering on their end.

Is this possible?

Upvotes: 3

Views: 8132

Answers (3)

Drew
Drew

Reputation: 195

To do this search against v1.1 of Twitter's API (which requires OAuth), you'd issue a GET request to the a URL structured like:

https://api.twitter.com/1.1/search/tweets.json?q=from:whitehouse+#sotu

See their Search API's "How to build a query" section. You'll be constrained to tweets over the last 7 days, though.

Upvotes: 2

Ravi
Ravi

Reputation: 301

I am reading the twitter documentation and they say right now it will include only 6-9 days of tweets. Link https://dev.twitter.com/docs/using-search

Upvotes: 3

Chris McFarland
Chris McFarland

Reputation: 6169

Twitter's Advanced Search lets you construct the query you desire. Unfortunately, search results only seem to be for tweets posted within the past 24 hours or so right now; might just be a temporary limitation, not sure.

In any case, your request URL might look something like this (note the JSON and Atom types):

http://search.twitter.com/search?q=%23HASHTAG+from:USERNAME http://search.twitter.com/search.json?q=%23HASHTAG+from:USERNAME http://search.twitter.com/search.atom?q=%23HASHTAG+from:USERNAME

But with the current timeframe limitation, it's not very practical.

Upvotes: 7

Related Questions