17

I am trying to search twitter tweets by a given hashtag. I am trying to get the correct http query, but I have no idea which one. I've tried a few but i can't find the correct one.

I should use the http://api.twitter.com/1/... link.

I already have a search http query by a given name which works correctly

http://api.twitter.com/1/statuses/user_timeline.json?screen_name=prayforjapan

Now I would like to search by a given hashtag (for example #prayforjapan)

I tried using a few, but can't find the correct one as I said before. Here's one I tried:

http://api.twitter.com/1/statuses/public_timeline.json?include_entities=true&hashtag=prayforjapan"

Does anyone know which one I should use?

Thanks!

Tjekkles
  • 5,352
  • 8
  • 36
  • 53

3 Answers3

35

You can simply fetch http://search.twitter.com/search.json?q=%23test to get a list of tweets containing #test in JSON, where %23test is #test URL encoded.

gnab
  • 9,251
  • 1
  • 21
  • 13
  • Yeah, I found that search too, but that one always gives an error in my code, that's why I think I should use the api.twitter. Could it be that it returns a different structure of JSON? – Tjekkles Mar 14 '11 at 08:32
  • It returns valid JSON, so if your code fails it might be buggy in some way? – gnab Mar 14 '11 at 09:12
  • Yeah, it returns JSON, but in a different order than the other :) – Tjekkles Mar 14 '11 at 09:20
  • Just want to add that to get data of next page add &page=2 where 2 is page no. example : http://search.twitter.com/search.json?q=%23test&page=2 –  Feb 27 '13 at 06:37
5

Just for people who come this post now. This current format works

https://api.twitter.com/1.1/search/tweets.json?q=%23test&include_entities=true
Derlin
  • 9,572
  • 2
  • 32
  • 53
Spikerr
  • 311
  • 1
  • 5
  • 16
1

I use the http://search.twitter.com/search.json?q=%23test format shown above, but in recent weeks this format has stopped working. It returns valid JSON, yes, but the return has zero tweets while a manual search of the hashtag on twitter.com shows one or more results. This happens with every hashtag I try. Has anyone else experienced this?

Edit: I've also noticed that adding a hyperlink to a tweet causes it to show up only in my feed, while it fails to show in either site search or JSON. I'm a Twitter novice; am I missing something basic here?