Search API returns only one tweet


#1

I have some python code that can either get a stream or do a search. The stream works fine, but when I switch to the search, I get only one result back no matter what I search for. Is this expected? Below is a snippet of my code.

Thanks for your time.


def fetchsamples():
  #url = "https://stream.twitter.com/1/statuses/sample.json"
  url = "https://api.twitter.com/1.1/search/tweets.json?q=%23obama"
  parameters = []
  response = twitterreq(url, "GET", parameters)
  for line in response:
    print line.strip()


#2

I think this has more to do with the default API search time window. For same query as yours(Obama) I could get 15 tweets, however when I tried to query for lets say %23IndianElections I was also getting a single result like you, which was tweeted somewhere in Aug, but on searching twitter with query there were tweets in June etc, so I wrote a test tweet with #IndianElections and when I queried using your code I could get two search results(including mine:)) so I think it has more to do with tweet time I think by default twitter API searches for 1 month or so. Anybody from Twitter team can validate this?


#3

This sounds likely. The search window is typically around 7 days so it will depend on how many tweets were posted with that term in that window.

Incidentally, there are several great Python libraries like tweepy that can help you with these kinds of searches without you having to supply the URL explicitly.