Working with Ranges in a REST API

Ancient Knowledge

This article is getting old. It was written in the ancient times and the world of software development has changed a lot since then. I'm keeping it here for historical purposes, but I recommend you check out the newer articles on my site.

A unique way of working with ranges in a more fluent way in a REST API. What is nice about this approach is its easy to hook up to javascript and is still a valid url scheme.

Simple search by month and year

/api/quote/count/by/month
/api/quote/count/by/month?year=2014
/api/quote/count/by/month?year=2014&month=4

Searching by year and inclusive months

/api/quote/count/by/month?year=2014&month=[1,2,3]

Searching by year and inclusive range of months (Jan - Sept)

/api/quote/count/by/month?year=2014&month=[1:9]

Searching by year and any month up to and including September

/api/quote/count/by/month?year=2014&month=[:9]

Searching by year and any month from February and after

/api/quote/count/by/month?year=2014&month=[2:]

Searching by year and specific months

/api/quote/count/by/month?year=2014&month=[7|10|11]