API: Sort the list of zettel metadata

00001012052000 · Info · (manual) · #api #manual #zettelstore

If not specified, the list of zettel is sorted descending by the value of the zettel identifier. The highest zettel identifier, which is a number, comes first. You change that with the “_sort” query parameter. Alternatively, you can also use the “_order” query parameter. It is an alias.

Its value is the name of a metadata key, optionally prefixed with a hyphen-minus character (“-”, U+002D). According to the type of a metadata key, the list of zettel is sorted. If hyphen-minus is given, the order is descending, else ascending.

If you want a random list of zettel, specify the value “_random” in place of the metadata key. “_sort=_random” (or “_order=_random”) is the query parameter in this case. If can be combined with “_limit=1” to obtain just one random zettel.

Currently, only the first occurrence of _sort is recognized. In the future it will be possible to specify a combined sort key.