Take the 2-minute tour ×
Stack Apps is a question and answer site for apps, scripts, and development with the Stack Exchange API. It's 100% free, no registration required.

I want to fetch questions from a certain offset. Not a minimum creation date, just an offset index, independent of the sort and order I'm using. How can I do this? Is it possible at all?

Page/pagesize are NOT suitable for me in this case, as I want to be able to pick an offset that is not dividable by the pagesize, too.

share|improve this question
add comment

1 Answer 1

I assume you mean an offset into questions ordered by question_id. That begs a lot of questions, but...

You can convert between question_id and creation_date given the knowledge that question_id increases monotonically. However, you can't guarantee the number of requests such an operation will take - though in practice more than 5 would be somewhat unusual*.

Make a query to /questions/{id} where id = desired offset, then make a request to /questions?fromdate={startdate}&sort=creation&order=asc where startdate = the creation date returned by the previous /questions/{id} query. That will give you a set of questions from the desired offset ordered by question_id. You can use fromdate to the same effect (minimum question_id to return) in most other queries.

The tricky part is if the question with the desired offset has been deleted, in which case you'll have to increment {id} until you find a subsequent question that has not.

*Such large gaps of deleted questions are indicative of periods of abuse that have been cleaned up subsequently.

share|improve this answer
    
Thanks for your elaborate answer. However, I didn't mean questions ordered by question_id. I meant any order. I know it is possible to get the desired range of questions with a maximum of two requests with page/pagesize parameters. I just wondered if it would be possible in one request. –  eWolf Jul 13 '10 at 10:32
    
@eWolf - no. You can fetch a set of ids using vectorized requests (/questions/1;2;3;4;5;6 for example, up until the path grows too large to handle) but there is no way to restrict returned values by question_id. –  Kevin Montrose Jul 13 '10 at 10:55
add comment

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .