6

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?

2 Answers 2

8

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.

0
2

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);
    }
}

You must log in to answer this question.

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