Skip to content

Filtering & Ordering

Marvin de Leon edited this page Apr 9, 2017 · 1 revision

Quick Explanation:

Filtering and Ordering, add: ?<filter>=<parameter> to the end of a GET request.

Multiple filters and/or ordering: ?<filter>=<parameter>&<filter>=<parameter>

You can apply these same filters to:
api/services
api/events/{event}/services
api/service_tags
api/services/{service}/service_tags

The default ordering is as follows:
Events by DATE ASCENDING
Services by NAME ASCENDING
ServiceTags by NAME ASCENDING

Filtering Examples

Filter by: ID

HTTP route Description:
GET api/services?filter-ids=<list of id's>
GET api/services?filter-ids=2 Returns only the service with Id 2
GET api/services?filter-ids=2,4,9 Returns the services with Ids 2, 4, and 9

Filter by: all except ID

HTTP route Description:
GET api/services?filter-except-ids=<list of id's>
GET api/services?filter-except-ids=2 Returns all services except the service with Id 2
GET api/services?filter-except-ids=2,4,9 Returns all services except the services with Ids 2, 4, and 9

Filter by: service tag ID

HTTP route Description:
GET api/services?filter-tag-ids=<list of id's>
GET api/services?filter-tag-ids=2 Returns only the services with the service tag with Id 2
GET api/services?filter-tag-ids=2,4,9 Returns the services with service tags of Ids 2, 4, or 9

Note: You may only use filter-tag-ids on Services, since Services contain ServiceTags, but obviously ServiceTags do not contain ServiceTags.

These endpoints don't accept filter-tag-ids:
api/service_tags
api/services/{service}/service_tags

Ordering Examples

Order: ASCENDING or DESCENDING

HTTP route Description:
GET api/services?order=<ASC,DESC>
GET api/services?order=DESC Changes the ordering to DESCENDING instead of the default ASCENDING

Order by: column name

HTTP route Description:
GET api/services?order-by=<id,name,cost>
GET api/services?order-by=id Changes the ordering to use ID instead of the default NAME