01 March, 2016

Working with Ranges in a REST API

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]

Tags: , , ,