Sort single select field via API

Hi, I am currently connecting to airtable data via the API. I am able to sort my response in certain fields using desc and asc. However for non text fields in particular single select fields where in the UI you would sort First-Last. What would the parameter be for sorting these fields?

Welcome to the community, @Cameron_Flanagan!

That isn’t possible with the “sort” parameter, but you can specify a “view” parameter instead of a “sort” parameter. In that case, the API will sort your records as they appear in that particular view.

One very important thing to note is that your records can NOT be grouped in your view. Your records must be ungrouped. If they are grouped, Airtable will sort your records in its own random unpredictable order. This is a bug in Airtable.

Thank you for the reply scott. The issue with the views is that is doesnt allow nice interaction with the data in custom UI over the top of the API. It seems rather restrictive. So are you saying there is no way to sort data that isnt of type long text or short text via the API?

Not sure what you’re asking or what you’re trying to accomplish. You can sort on any field you want, not just long text or single line text fields.

Hi Scott, Apologies for the confusion here.

The issue I am having is when making get requests to the airtable API using the sort parameter defined in the documentation.
This works for me for certain fields. But when I do the same thing for a field that is a single select field the response I get back does not appear to be sorted in anyway. So am I doing something wrong is there another value I should pass for direction for these type of fields?

I just tested this on my end, and it works just fine for me. Are you sorting on more than one field in your Get Request, or just the one field? Why don’t you post your entire Get Request here.

This is just one field. This is working for other types of field but when I do something like the below where N is a single select field the results do not come back in a sorted order.
[14/07/2021 10:18] Flanagan, Cameron

curl "" \

-H “Authorization: Bearer {{API_KEY}}”

The sort order for Single Select fields is not evaluated alphabetically… it is evaluated by the order that your single select options are listed within the field customization options.

You can see this within the Airtable interface itself by trying to sort on a single select field.

If you want them alphabetically, you have to manually alphabetize the options within the Airtable interface by clicking on the “sort alphabetically” button within the field options (or you can manually alphabetize them).

Alternatively, you could create a formula field that equals the single select field, and then sort by that formula field instead.


Thanks Scott this has cleared things up. After doing the sort in the UI results are returned as expected.

1 Like

Glad I could help! :slight_smile: If you don’t mind, could you please mark my comment above as the solution to your question? This will help other people who have a similar question in the future. :slight_smile:

This topic was solved and automatically closed 3 days after the last reply. New replies are no longer allowed.