June 23, 2011
Today I happened upon this curiosity — occasionally a tweet returned by the Twitter API will have different values for id and id_str! Here’s an example from my timeline:
This can cause problems if you’re polling a user’s timeline and using the since_id parameter. My requests had since_id equal to the id 79278346831273980, and so it continuously returned this tweet as a new result.
This post from Taylor Singletary clarified the problem. Apparently some JSON implementations can’t handle integers as large as twitter’s tweet IDs, and that’s why the id_str field was introduced.
The take-away is that you should always prefer id_str over id.