I have problem with my code. I want to download more than 100 tweets with one query. Is it possible to get more than 100 tweets using the Twitter API?
My code:
module.exports = function(text, callback) {
console.log("Test: " + text);
var twitterClient = new twitter(config);
var response = [], dbData = []; // to store the tweets and sentiment
console.log(1, twitterClient.search);
twitterClient.search(text, {count: 500}, function(data) {
console.log("Obiekt: " + data);
for (var i = 0; i < data.statuses.length; i++) {
var resp = {};
resp.tweet = data.statuses[i];
resp.sentiment = sentimentAnalysis(data.statuses[i].text);
dbData.push({
tweet: resp.tweet.text,
score: resp.sentiment.score
});
response.push(resp);
};
db.sentiments.save(dbData);
callback(response);
});
}
2
Answers
No Its not allowed by twitter api.
count: 100
is max limit.Search Api Twitter
Although it is not technically allowed by the Twitter API to query more than 100 tweets at once, that only acounts for tweets in a single query, which means you could technically make a query, fetch 100 tweets, push them to an array, then repeat the query with the
max_id
parameter set to the lowest ID you had in your previous query, and push that to the array again, and so on.The limit for this approach would be 18000 / 15min or 45000 / 15min if you’re using app auth.