How to Fetch Data from an External API in Airtable

Aug 19, 2024Zayyad Muhammad Sani

In this tutorial, you'll learn how to fetch data from an external API in Airtable. You'll connect to the REST countries API and import the names, flags, regions, and populations of countries into an Airtable base.

What is an External API in Airtable?

An external API is a web service that you can use to connect with other applications and web services outside Airtable. External APIs especially come in handy when importing data from another platform into Airtable.

In the following sections, we'll create a request in Data Fetcher and import data from the REST countries API.

Installing Data Fetcher

1. Add the Data Fetcher extension to your Airtable base.

2. Once you’ve added the extension, sign in to Data Fetcher or sign up if you don’t have an account.

sign up for data fetcher.png

3. Once you've logged in to Data Fetcher, click Create your first request.

create your first request logo 2 smaller.png

How to Fetch Data from an External API in Airtable

Follow these steps to configure the request:

1. Under Application, select Custom.

select custom request.png

2. Name the request "Fetch countries data".

name-request-countries-data.png

3. Enter https://restcountries.com/v3.1/all under URL. Make sure the request's method is GET.

url-countries-data.png

If we run the request now, it will return many country-related data we're not interested in. We'll add parameters to the request so it returns the fields we want in the response data.

4. Click + Add under Parameters.

add-parameter-countries-data.png

5. Enter fields under Parameter, then name,flags,region,population under Value.

added-fields-parameter.png

6. Click Save and Run in the bottom right corner.

Mapping Response Fields

Once you've completed the previous steps, Data Fetcher will connect to the external API and take you to Response Field Mapping. On this page, you'll select and configure the fields you want to import from the response data.

response-field-mapping-countries-data.png

If you want to see the raw JSON response from the external API, you can click the right arrow icon (->) in the top left of the screen to open the settings sidebar, then click "Response preview".

Notice how multiple fields start with "Name" and "Flags". This API returns different names of countries based on how they're called around the world. As for the flags, the API returns two image types and a description of the flag. We only need a country's common name and one flag image, so we'll deselect the other fields and pick the ones we want.

1. Click Deselect All.

deselect-all-countries-data.png

2. Select the following fields and use the mapping below:

  • Name common -> Existing field Name
  • Flags png -> New field Flag
  • Region -> New field Region (change field type to single select)
  • Population -> New field Population
name-and-flag-fields-countries.png

region-and-population-countries.png

3. Click Save and Run in the bottom right corner.

Check your output table and you should see the list of countries and their data.

countries-data-imported.png

Let's summarize the steps for connecting to an external API in Airtable:

  • Get the URL you'll use to access data from the API.
  • Install Data Fetcher in your Airtable base.
  • Create a request and configure it to match your needs
  • Map the response fields from the external API to Airtable.
  • Run the request.

That's all for this tutorial. Check out our blog to see what other external API requests you can make with Airtable and Data Fetcher.

Related Posts

How to Import Data into Airtable Without Duplicates

How to Import Data into Airtable Without Duplicates

Oct 7, 2024

Zayyad Muhammad Sani

Custom RequestsData Fetcher
How to Connect to an OAuth 1.0 API in Airtable

How to Connect to an OAuth 1.0 API in Airtable

Sep 20, 2024

Zayyad Muhammad Sani

Custom Requests
How to Make an HTTP POST Request in Airtable

How to Make an HTTP POST Request in Airtable

Aug 20, 2024

Zayyad Muhammad Sani

Custom Requests