skip to Main Content

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


  1. No Its not allowed by twitter api. count: 100 is max limit.

    count optional

    The number of tweets to return per page, up to a maximum of 100.
    Defaults to 15. This was formerly the “rpp” parameter in the old
    Search API.

    Example Values: 100

    Search Api Twitter

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search