Skip to content

Instantly share code, notes, and snippets.

@Aslan11
Created March 23, 2016 23:10
Show Gist options
  • Save Aslan11/2c7e687db75357080d37 to your computer and use it in GitHub Desktop.
Save Aslan11/2c7e687db75357080d37 to your computer and use it in GitHub Desktop.
Endpoint Design Question - Filtering
PROBLEM:
I need to filter on a list of IO's based on active state. Given that this will be passed in from a querystring param,
how should I design the endpoint?
1. Solution 1 - Single Boolean
GET /v2/ios/?active=true -> Returns all the ACTIVE IO's
GET /v2/ios/?active=false -> Returns all the INACTIVE IO's
GET /v2/ios/ -> Returns both ACTIVE and INACTIVE IO's
2. Solution 2 - Double Boolean
GET /v2/ios/?active=true -> Returns all the ACTIVE IO's
GET /v2/ios/?inactive=true -> Returns all the INACTIVE IO's
GET /v2/ios/ -> Returns Both ACTIVE and INACTIVE IO's
3. Solution 3 - String
GET /v2/ios/?type=active -> Returns all the ACTIVE IO's
GET /v2/ios/?type=inactive -> Returns all the INACTIVE IO's
GET /v2/ios/?type=both -> Returns Both ACTIVE and INACTIVE IO's
GET /v2/ios/ -> Returns Both ACTIVE and INACTIVE IO's
@mark-kawakami-zefr
Copy link

In this case, I definitely like #1 because it maps to how the data is actually represented when it comes back from the API

@mvillalobosj
Copy link

agreed, solution 1 is the best way to go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment