Sorting and Filtering Requests from Airtable

With the new APIs & Services feature, you’re able to save the base URL for any REST API which will allow you to easily reuse and modify your request. We’ll go over an example of this with sorting and filtering Airtable query results.

The Base

For this example, we’ll be using a simple Base with two Tables that was created to keep track of favorite album releases.


Once your Base is ready, you can go to Airtable’s API Documentation found under the ‘Help’ button in the top right corner of your Base.


Make sure you check the ‘show API key’ checkbox to generate your key — we’ll save this in the Global Variables settings back in Draftbit.

For previous Airtable tutorials, we’ve had you copy and paste the entire URL in the example generated, but for this one, we’re going to leave out the 2019 (the Table Name) at the end.

If you go further down to the List Records section of the documentation, you’ll see a section discussing the ways you can filter and sort your query. Keep this open, we’ll come back to this later.

In Draftbit

To configure this in the APIs and Services, open the Project Settings by clicking the gear in the column on the left of the Builder and go to the Variables tab. Give the new variable a name (Key), paste your API Key in the Value section and click the ‘Add’ button.

Next, go to the Services tab. Set up a new REST API, give it a name, add the Airtable URL under Config, then add the API key you saved in Global Variables under Headers. Once finished, you can save and exit the modal.


Once you have your Fetch component set up on your screen, you can go to the Data tab in the Properties Panel and open the Build Query modal. In the modal, you’ll see a dropdown to select a Base API or Service. Select the API you saved in the dropdown and it’ll auto-populate the Endpoint input. With this setup, you can use the filtering and sorting options provided to you in the List Records section in Airtable’s API.


Airtable has made it super easy to generate the proper URL to filter and sort your results with its API Encoding Tool (If you access this tool directly from the Airtable API documentation, it’ll have the Base ID and Table fields pre-populated for you). Once you’ve filled in the fields you need, you can copy the portion of the URL after the Base ID to use in Draftbit.

Here’s an example to generate a URL that will return a list of Albums in the 2019 Table sorted by the release month in ascending order.


Once you’re back in Draftbit, you can paste the necessary portion of the URL at the end of your saved API in the Build Query modal. Test the request and you’ll see the results of your sort/filter appear!


Make sure to refer back to Airtable’s API documentation to see the full list of query parameters you can use in your own requests!