It seems like the data returned from the /events
endpoint is flawed by being returned in descending order. For example:
{
"items": [
{
"event_type": "comment_posted",
"event_id": 11811324,
"creation_date": 1329699806
},
{
"event_type": "question_posted",
"event_id": 9354990,
"creation_date": 1329699800
},
...
}
Wouldn't it make more sense for the stream to be returned in ascending order? That way you could clearly see that the creation_date
of the last item in the stream is the since
date of the next time you request events. As the API stands now, I have to do this:
- Request events since time A
- Check to see if the last event occurred at time A
- If it didn't, try the request again, with a different page
- Repeat the previous two steps until you find time A
In other words, it looks like this:
You jump forward in time, then make a number of small steps back, then jump forward, then make a number of small steps back...
And you have to do this because the event stream comes back in the wrong order.
If the event stream came back in ascending order (with the newest event last in the array), then you'd only have to do this:
Obviously the default sorting of the event stream can't be changed at this point, but can there be a new (and optional) sort field, so that I can request /events?since=123456789&sort=asc
? That would make things so much simpler.