Chapter 4. Sorting in the API


To give you examples that are easy to follow, we use the following URL throughout this guide:

https://<server name>/api/v2/groups/

Procedure

  • To specify that {{ model_verbose_name_plural }} are returned in a particular order, use the order_by query string parameter on the GET request:

    https://<server name>/api/v2/model_verbose_name_plural?order_by={{ order_field }}
    • Prefix the field name with a dash (-) to sort in reverse:

      https://<server name>/api/v2/model_verbose_name_plural?order_by=-{{ order_field }}
    • You can specify the sorting fields by separating the field names with a comma (,):

      https://<server name>/api/v2/model_verbose_name_plural?order_by={{ order_field }},some_other_field
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.