Get-statuses-user_timeline next to a given tweet ID


#1

Let’s say my timeline is like this (tweet id, date, text) :

10, oct 05 08:20, text10
09, oct 05 08:15, text09
08, oct 05 08:10, text08
07, oct 05 08:08, text07
06, oct 05 08:05, text06
05, oct 05 07:55, text05
04, oct 05 07:50, text04
03, oct 05 07:49, text03
02, oct 05 07:47, text02
01, oct 05 07:45, text01

I am given a tweet ID, for example 06. I need to get the 2 nexted tweets forward and backward, i.e. : 07,08 and 05,04.

Working with https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-user_timeline and https://developer.twitter.com/en/docs/tweets/timelines/guides/working-with-timelines :

I can get tweets 04 and 05 with parameters max_id: 06, count: 2 but i couldn’t manage to get 07 and 08 because since_id: 06, count: 2 returns 09,10.

Moreover i’m working with id_str so i can’t add 1 or remove 1 to the ids if needed.

So please, what is the logic to get ids 04,05,06,07,08 given id 06 ? Thanks for your help.


#2

I would actually recommend that you work with our search API instead.

You could use the from:interior operator to search for Tweets posted by the specific user and the since_id and max_id to limit the Tweets to just the 5 that you are looking for.


#3

Thanks but in that case i am limited with 7 days past only.
I need older tweets, so the timeline endpoint is best.
Of course, i don’t want to download all the 3200 latest tweets to search in.
One or two requests would be better for Twitter and for me.


#4

Could you use max_id: 08, count: 5?


#5

Yes it should work but i have to find this id 08 programmatically.

In fact i should repost my question as :
How to get a user thread given a tweet id of this thread ?

Is there an API or a workaround for this ?


#6

We do not provide an API that supports this. Sorry for the inconvenience.


#7