[ACCEPTED]-What exactly does 'since_id' and 'max_id' mean in the Twitter API-tweets

Accepted answer
Score: 38

since_id and max_id are both very simple 24 parameters you can use to limit what you 23 get back from the API. From the docs:

since_id - Returns 22 results with an ID greater than (that 21 is, more recent than) the specified ID. There 20 are limits to the number of Tweets which can 19 be accessed through the API. If the limit 18 of Tweets has occured since the since_id, the 17 since_id will be forced to the oldest 16 ID available. max_id - Returns results with 15 an ID less than (that is, older than) or equal 14 to the specified ID.

So, if you have a given 13 tweet ID, you can search for older or newer 12 tweets by using these two parameters.

count is 11 even simpler -- it specifies a maximum number 10 of tweets you want to get back, up to 200.

Unfortunately 9 the API will not give you back exactly what 8 you want -- you cannot specify a date/time 7 when querying user_timeline -- although you can specify 6 one when using the search API. Anyway, if 5 you need to use user_timeline, then you 4 will need to poll the API, gathering up 3 tweets, figuring out if they match the parameters 2 you desire, and then calculating your stats 1 accordingly.

Score: 13

The max_id = top of tweets id list . since_id 2 = bottom of tweets id list .

for more : get 1 a deep look in the last diagram .. here

Score: 2

The max_id and since_id are used to prevent 20 redundancy in the case of Twitter API calls. Visualize 19 the tweets coming in as piling onto a stack. One 18 API call has to specify how many (count) tweets 17 will be processed. But as this call is made, new 16 tweets may be added. In that case, if you 15 draw out a stack and run through the process, you 14 notice that there can be some 'fragmentation' or 13 sections of unprocessed tweets stuck in 12 between processed ones. This is visible 11 in below image as well.

enter image description here

To get around this 10 problem, two parameters are used to keep 9 track of the latest/greatest ID tweet previously 8 processed (since_id) and the oldest/lowest 7 ID tweet recently processed (max_id). The 6 since_id points to the bottom of the 'fragment' and 5 the (max_id-1) points to the top of the 4 'fragment'. (Note that the max_id is inclusive 3 unlike the since_id) So, the parameters 2 together keep track of which part of the 1 tweet stack still needs to be processed.

More Related questions