Twitter - i only recieve 20 tweets from the user_timeline












0















var options = {
method: 'GET',
url: 'https://api.twitter.com/1.1/statuses/user_timeline.json?',
qs: { "screen_name": "Screen_name"} ,
json: true,
headers: {
"Authorization": "Bearer " + token.access_token
}
};


request(options, function(error, response, body){
console.log("length",body.length)
});


i am trying to get all tweets but for some reason i only get 20, eventought the api call can get up to 3200 tweets.



So i am wondering how can i get all the tweets of this account (currently 700+)
i saw a count being listed but for some reason i cant find a way to start a segment.



Hopefully someone can help me.



EDIT:



after the answer of pii_kee , i came to the conclusion that this is what needs to be done to get all tweets :



    var firstOptions = {
method: 'GET',
url: 'https://api.twitter.com/1.1/statuses/user_timeline.json',
qs: {"screen_name": "Company", "count": 200},
json: true,
headers: {
"Authorization": "Bearer " + token.access_token
}
};
var array = ;
var go = true;
async.whilst(function () {
return go;
},function(next){
request(firstOptions, function (error, response, body) {
firstOptions.qs.max_id = body[body.length - 1].id;
array = array.concat(body);
if(body.length !== 200) {
go = false;
}
next();
});
});









share|improve this question

























  • Do you can show a common returning from twitter API? Maybe it return the next page path for a next API call.

    – Lucas Costa
    Nov 20 '18 at 13:46











  • @LucasCosta i have added a common response, i do not see a nextpage path listed anywhere.

    – Lars Hendriks
    Nov 20 '18 at 13:54
















0















var options = {
method: 'GET',
url: 'https://api.twitter.com/1.1/statuses/user_timeline.json?',
qs: { "screen_name": "Screen_name"} ,
json: true,
headers: {
"Authorization": "Bearer " + token.access_token
}
};


request(options, function(error, response, body){
console.log("length",body.length)
});


i am trying to get all tweets but for some reason i only get 20, eventought the api call can get up to 3200 tweets.



So i am wondering how can i get all the tweets of this account (currently 700+)
i saw a count being listed but for some reason i cant find a way to start a segment.



Hopefully someone can help me.



EDIT:



after the answer of pii_kee , i came to the conclusion that this is what needs to be done to get all tweets :



    var firstOptions = {
method: 'GET',
url: 'https://api.twitter.com/1.1/statuses/user_timeline.json',
qs: {"screen_name": "Company", "count": 200},
json: true,
headers: {
"Authorization": "Bearer " + token.access_token
}
};
var array = ;
var go = true;
async.whilst(function () {
return go;
},function(next){
request(firstOptions, function (error, response, body) {
firstOptions.qs.max_id = body[body.length - 1].id;
array = array.concat(body);
if(body.length !== 200) {
go = false;
}
next();
});
});









share|improve this question

























  • Do you can show a common returning from twitter API? Maybe it return the next page path for a next API call.

    – Lucas Costa
    Nov 20 '18 at 13:46











  • @LucasCosta i have added a common response, i do not see a nextpage path listed anywhere.

    – Lars Hendriks
    Nov 20 '18 at 13:54














0












0








0








var options = {
method: 'GET',
url: 'https://api.twitter.com/1.1/statuses/user_timeline.json?',
qs: { "screen_name": "Screen_name"} ,
json: true,
headers: {
"Authorization": "Bearer " + token.access_token
}
};


request(options, function(error, response, body){
console.log("length",body.length)
});


i am trying to get all tweets but for some reason i only get 20, eventought the api call can get up to 3200 tweets.



So i am wondering how can i get all the tweets of this account (currently 700+)
i saw a count being listed but for some reason i cant find a way to start a segment.



Hopefully someone can help me.



EDIT:



after the answer of pii_kee , i came to the conclusion that this is what needs to be done to get all tweets :



    var firstOptions = {
method: 'GET',
url: 'https://api.twitter.com/1.1/statuses/user_timeline.json',
qs: {"screen_name": "Company", "count": 200},
json: true,
headers: {
"Authorization": "Bearer " + token.access_token
}
};
var array = ;
var go = true;
async.whilst(function () {
return go;
},function(next){
request(firstOptions, function (error, response, body) {
firstOptions.qs.max_id = body[body.length - 1].id;
array = array.concat(body);
if(body.length !== 200) {
go = false;
}
next();
});
});









share|improve this question
















var options = {
method: 'GET',
url: 'https://api.twitter.com/1.1/statuses/user_timeline.json?',
qs: { "screen_name": "Screen_name"} ,
json: true,
headers: {
"Authorization": "Bearer " + token.access_token
}
};


request(options, function(error, response, body){
console.log("length",body.length)
});


i am trying to get all tweets but for some reason i only get 20, eventought the api call can get up to 3200 tweets.



So i am wondering how can i get all the tweets of this account (currently 700+)
i saw a count being listed but for some reason i cant find a way to start a segment.



Hopefully someone can help me.



EDIT:



after the answer of pii_kee , i came to the conclusion that this is what needs to be done to get all tweets :



    var firstOptions = {
method: 'GET',
url: 'https://api.twitter.com/1.1/statuses/user_timeline.json',
qs: {"screen_name": "Company", "count": 200},
json: true,
headers: {
"Authorization": "Bearer " + token.access_token
}
};
var array = ;
var go = true;
async.whilst(function () {
return go;
},function(next){
request(firstOptions, function (error, response, body) {
firstOptions.qs.max_id = body[body.length - 1].id;
array = array.concat(body);
if(body.length !== 200) {
go = false;
}
next();
});
});






node.js twitter






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 8:19







Lars Hendriks

















asked Nov 20 '18 at 13:41









Lars HendriksLars Hendriks

56812




56812













  • Do you can show a common returning from twitter API? Maybe it return the next page path for a next API call.

    – Lucas Costa
    Nov 20 '18 at 13:46











  • @LucasCosta i have added a common response, i do not see a nextpage path listed anywhere.

    – Lars Hendriks
    Nov 20 '18 at 13:54



















  • Do you can show a common returning from twitter API? Maybe it return the next page path for a next API call.

    – Lucas Costa
    Nov 20 '18 at 13:46











  • @LucasCosta i have added a common response, i do not see a nextpage path listed anywhere.

    – Lars Hendriks
    Nov 20 '18 at 13:54

















Do you can show a common returning from twitter API? Maybe it return the next page path for a next API call.

– Lucas Costa
Nov 20 '18 at 13:46





Do you can show a common returning from twitter API? Maybe it return the next page path for a next API call.

– Lucas Costa
Nov 20 '18 at 13:46













@LucasCosta i have added a common response, i do not see a nextpage path listed anywhere.

– Lars Hendriks
Nov 20 '18 at 13:54





@LucasCosta i have added a common response, i do not see a nextpage path listed anywhere.

– Lars Hendriks
Nov 20 '18 at 13:54












1 Answer
1






active

oldest

votes


















1














Try adding count: 200 in the qs object to get about 200 tweets per request. To get older tweets you have to set the max_id parameter properly, otherwise it will return most recent tweets only. Take a look at the reference of statuses/user_timeline API endpoint for detailed meaning of these parameters.



Also, try reading this guide on working with timelines using this method.






share|improve this answer


























  • I added my code that works for me to the answer. thanks for your help this did the trick. for some reason i missed the entire guide on the twitter website.

    – Lars Hendriks
    Nov 21 '18 at 8:04











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53394342%2ftwitter-i-only-recieve-20-tweets-from-the-user-timeline%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Try adding count: 200 in the qs object to get about 200 tweets per request. To get older tweets you have to set the max_id parameter properly, otherwise it will return most recent tweets only. Take a look at the reference of statuses/user_timeline API endpoint for detailed meaning of these parameters.



Also, try reading this guide on working with timelines using this method.






share|improve this answer


























  • I added my code that works for me to the answer. thanks for your help this did the trick. for some reason i missed the entire guide on the twitter website.

    – Lars Hendriks
    Nov 21 '18 at 8:04
















1














Try adding count: 200 in the qs object to get about 200 tweets per request. To get older tweets you have to set the max_id parameter properly, otherwise it will return most recent tweets only. Take a look at the reference of statuses/user_timeline API endpoint for detailed meaning of these parameters.



Also, try reading this guide on working with timelines using this method.






share|improve this answer


























  • I added my code that works for me to the answer. thanks for your help this did the trick. for some reason i missed the entire guide on the twitter website.

    – Lars Hendriks
    Nov 21 '18 at 8:04














1












1








1







Try adding count: 200 in the qs object to get about 200 tweets per request. To get older tweets you have to set the max_id parameter properly, otherwise it will return most recent tweets only. Take a look at the reference of statuses/user_timeline API endpoint for detailed meaning of these parameters.



Also, try reading this guide on working with timelines using this method.






share|improve this answer















Try adding count: 200 in the qs object to get about 200 tweets per request. To get older tweets you have to set the max_id parameter properly, otherwise it will return most recent tweets only. Take a look at the reference of statuses/user_timeline API endpoint for detailed meaning of these parameters.



Also, try reading this guide on working with timelines using this method.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 21 '18 at 9:29

























answered Nov 20 '18 at 20:32









pii_kepii_ke

1,2201019




1,2201019













  • I added my code that works for me to the answer. thanks for your help this did the trick. for some reason i missed the entire guide on the twitter website.

    – Lars Hendriks
    Nov 21 '18 at 8:04



















  • I added my code that works for me to the answer. thanks for your help this did the trick. for some reason i missed the entire guide on the twitter website.

    – Lars Hendriks
    Nov 21 '18 at 8:04

















I added my code that works for me to the answer. thanks for your help this did the trick. for some reason i missed the entire guide on the twitter website.

– Lars Hendriks
Nov 21 '18 at 8:04





I added my code that works for me to the answer. thanks for your help this did the trick. for some reason i missed the entire guide on the twitter website.

– Lars Hendriks
Nov 21 '18 at 8:04


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53394342%2ftwitter-i-only-recieve-20-tweets-from-the-user-timeline%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

ts Property 'filter' does not exist on type '{}'

mat-slide-toggle shouldn't change it's state when I click cancel in confirmation window