Skip to main content
Sorting is available for most Ads API collection endpoints (that return a list of objects). Depending on the endpoint, you will find various parameters enabled for sorting. Most fields returned by these parameters (except for IDs and ENUMs) will be sortable.

Getting Started

In your API request simply append sort_by=[attribute name]-[asc/desc] where the attribute is a valid attribute that is returned in the JSON of your GET request. For example, you can use ?name-asc to sort by name alphabetically or ?name-desc to sort in reverse.

Going Deeper

Below is a sample API request to return all line items by the bid_amount_local_micro in descending order: twurl -H ads-api.x.com "/5/accounts/k9w0oe/line\_items?sort\_by=bid\_amount\_local_micro-desc"