Skip to main content

Sorting Records

How to sort records in the REST API

Written by Lenka Haringerová

Records can, of course, be sorted. The list of values you can sort by depends on the specific record type.

Sorting is controlled by the URL parameter order. This parameter can be specified multiple times.

Example: /c/firma/adresar?order=nazev


Sort direction

You can control whether to sort in ascending (order=nazev@A) or descending (order=nazev@D) order.

⚠️ @A means ascending, @D means descending. Without a suffix, sorting is ascending.

Examples:

  • /c/firma/adresar?order=nazev — sorts the address book by the nazev property in ascending order

  • /c/firma/adresar?order=nazev@D — descending order

For compatibility with certain implementations, you can also use the sort and dir parameters (which take the values ASC and DESC).


Sorting by relation properties

The API allows sorting by relation properties, but only at the 1st level. For example, you can specify ?order=stredisko.nazev or ?order=stat.kod. If you specify only the relation name (?order=stat), the relation's default sort order will be used.

ℹ️ Nesting into a second level (e.g., ?order=typDokl.radaPrijem.kod) is not supported and will result in a 400 error stating that the property does not exist.


Default sorting

If the order parameter is not specified, records are sorted by ID. Some record types are an exception and are also sorted by additional properties — documents are sorted by datVyst, and exchange rates are sorted by platiOdData and mena.

Did this answer your question?