dipole_moment
dipole_moment

Reputation: 5864

Specifying sort order in a JSON API

My team recently adopted the json api convention. In the documentation for the api sorting is not addressed.

They do however address filtering in the recommendations page but in my opinion, sorting is not part of filtering since filtering is used to reduce a set while sorting is used to re-order a set.

Given the json api convention, I'd like to know:

Upvotes: 14

Views: 12728

Answers (1)

t-sauer
t-sauer

Reputation: 841

Sorting is actually documented on the website: http://jsonapi.org/format/#fetching-sorting

Short summary:

  • use sort as the parameter name
  • if you need to sort by multiple attributes, comma separate them (e.g. sort=lastname,forename
  • if you want to specify the order, use a plus or minus in front of the attribute name (e.g. sort=-lastname,forname), the default order is ascending

Upvotes: 26

Related Questions