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.

Several of the api methods (e.g. questions) have min and max parameters with the following description:

min (optional)

  • Minimum of the range to include in the current .
  • number

max (optional)

  • Maximum of the range to include in the current .
  • number

This seems incomplete. Can anyone explain what these parameters are for?

share|improve this question
add comment

2 Answers 2

up vote 8 down vote accepted

Yeah... These are kind of complicated, but very flexible. They're also getting better docs soon-ish.

Basically, min & max are the range of the sorted results to return.

So, if you order a list of questions (pick your API method of choice) by votes, you can set min to 5 and max to 10 to only return questions that have a score of at least 5 and no more than 10.

If you were to sort by creation, you could instead only return questions created between (inclusive) the 1st and 15th of June 2009 by setting min to 1243832400 and max to 1245042000.

Comparing pure strings (as in name) gives you a lexographic range though the exact one is something of an implementation detail.

Not specifying min or max causes that end of the range to by unbound. So you could use get all questions with at least a score of 10 by setting min to 10, sort to votes, and omitting max on the appropriate methods.

share|improve this answer
    
Thanks for the detailed explanation. –  Bill the Lizard May 21 '10 at 2:20
add comment

It may be useful to review the test cases in the sample app.

public void VotesMinMax()
{
    // min=2, max=4
    var coms = ApiProxy.GetUserCommentsByVotesWithRange(1, 1, 50, 2, 4);
    Assert.IsTrue(coms.Count() > 0, "Count");

    int lastVotes = Int32.MaxValue;

    foreach (var com in coms)
    {
        if (com.VoteCount > lastVotes)
            Assert.Fail("comments not ordered by Score");

        lastVotes = com.VoteCount;

        Assert.IsTrue(com.VoteCount <= 4 && com.VoteCount >= 2);
    }
}
share|improve this answer
add comment

You must log in to answer this question.

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