How to get all current new tweets?

nodejs
api

#1

Hello, so I am fairly new to twitter’s API and even newer to using in a Node.JS setting for my twitter bot. I want to search all the tweets that are currently being posted in order to produce a sort of chart that measures what is twitter talking about now (politics, sports, etc.).

Now, my understanding, in order to search a tweet you have to give it some sort of parameter as follows:

var params = {
 q: '#aprilfools, #aprilfoolsday',  // REQUIRED
     result_type: 'recent', //recent tweets only.
      lang: 'en'
}

But I am not sure how I can include a time period in it, I tried looking it up, but it did not help or the answer wasn’t actually working. May have used the old API most likely. SO I guess just to wrap it, how can I fetch all tweets currently posted between a specific time period without having to specify a query parameter?


#2

Seems like you want something like (#aprilfools OR #aprilfoolsday) since:2017-04-01 until:2017-04-02 in your q if you want to get tweets between April 1st and 2nd for example. Types of queries you can make are detailed in https://dev.twitter.com/rest/public/search

Remember that REST API only indexes last week of tweets, so older ones are not available (web search is different and indexes older tweets)


#3

I see, how would I structure that query from within my node.js using those params that I have in place? I tried doing it without the query and typing both since and until, but I never got anything back as a result. Also, would I be using search/tweets or statuses/user_timeline for my get requests?

The documentation is somewhat lacking all things considered. Especially how their url examples never work.