V1
The JourneyApps API (V1) → 8. Sorting
Sorting
This parameter allows you to specify the order in which objects of a particular type are retrieved.
Relative URL | HTTP Request Method |
---|---|
/api/v1/object-type.format?sort[attribute]=direction | GET |
Note: Replace object-type with the type of object that you wish to retrieve (as defined in your app's Data Model), for example 'person', 'job' or 'asset'. Replace format with the response data format (
json
or xml
), or leave it out. Replace attribute with the desired attribute name, and replace direction with a value defined below.
Parameters
Sort criteria are specified as a URL-encoded sort
hash. Valid keys for this hash are names of the attributes in that object-type. Sort directions can expressed in javascript style - 1
or -1
- or human-readable: asc
, ASC
, desc
or DESC
Response
The response will contain a list of objects sorted by the specified attribute. The format of the objects is the same as for listing all objects (please refer to the Retrieving All Objects section.)
Example
Note: When using curl with queries you have to either escape the square brackets with a backslash (
Sort order - human readable
Sort order - javascript style
\[
) or add the -g
option to turn off curl's globbing functionality
Next Section:
9. Counting, Limiting & Skipping
Previous Section
Next Section