In this tutorial, you'll learn how to make HTTP GET requests in Airtable using the Data Fetcher extension. You'll get a list of football competitions from this football-data API and populate an Airtable base with the data.
As the name implies, GET requests allow clients to fetch data from a web service on the Internet or a local network. We use GET requests directly or indirectly through Application Programming Interfaces (APIs). APIs allow applications or web services to communicate with each other using a set of rules. For example, you communicate with Instagram's API when you fetch the latest posts, but the app does all the hard work for you in the background.
GET requests are part of a group of HTTP request methods. Other methods include POST, PUT, DELETE, and PATCH. You can read more about the different HTTP methods here.
Add the Data Fetcher extension to your Airtable base.
Once you’ve added the extension, sign in to Data Fetcher or sign up if you don’t have an account.
APIs usually offer multiple endpoints so that users can access different functionalities and retrieve specific data. The football-data API has many endpoints, such as teams, competitions, matches, persons, and areas. Since we want to import Spanish competitions data, we'll connect to the competitions endpoint.
Whenever you want to run a request in Data Fetcher, you'll combine the API's base URL with the path to an endpoint. In our case, we'll combine https://api.football-data.org/v4
with /competitions
.
Follow the steps below to make an HTTP GET request in your Airtable base and fetch the competitions data:
1. Open Data Fetcher in your Airtable base, then click Create your first request.
2. Select Custom under Application.
3. Rename the request to "Import football competitions".
4. Copy and paste the competitions endpoint URL into the URL input.
http://api.football-data.org/v4/competitions
5. Click Add + under Parameters.
GET request parameters help filter the data you fetch from an API. We're adding the areas
parameter to the request because we only want to fetch Spanish football competitions. If we're getting all football competitions, we'll run the request without the parameter.
6. Enter 'areas' under Parameter and '2224' under Value.
The areas
parameter tells the football-data API to return the competitions in the areas we specify in the request. Each area in the API has a unique ID, so we can include one or more IDs to fetch competitions from specific areas. In this case, we're only fetching competitions from Spain, which has an area ID of 2224.
Notice how the URL has changed since we added the parameter. This is how URLs look with parameters applied; you've probably seen something similar in your browser address bar before.
7. Click Save and Run in the bottom right corner.
Data Fetcher will make the HTTP GET request, and take you to Response Field Mapping. On this page, you'll choose fields from the response data that you want to import into your table.
You can map each field to an existing field in your table using the Existing field option, or create a new field with the New field option. Data Fetcher predicts field types in the response data, but you can change a field's type using the dropdown next to the new field's name.
The response data contains 30 fields, but we'll only use 5 of them:
1. Click Deselect All.
2. Click the checkbox next to the fields you want to keep and name them according to the mappings below.
Note: You'll have to scroll to the right to see some of the fields, or you can use the Find field search bar.
3. Click Save and Run in the bottom right corner.
Check your output table, and you should see the list of Spanish football competitions.
Besides parameters, you can add authorization and headers to your GET requests in Data Fetcher.
Authorization is used to get access to certain features of APIs or APIs that require user accounts. For example, football-data requires users to sign up for a plan to get access to other endpoints and make more requests per minute.
You can use authorization in Data Fetcher by clicking the Authorization tab, selecting the authorization type and entering your credentials.
Request headers are information included in HTTP requests to give servers more details about the request a client sends. For example, a request might include a User-Agent header containing details about the user's browser and operating system. Other types of request headers are used for authentication, working with cookies, etc.
On the other hand, servers use response headers to send information to tell clients more about a response. Since we only make requests in Data Fetcher, we'll use request headers. You can learn more about headers in this article.
Use headers in Data Fetcher by clicking the Headers tab and adding the data you want to send.
You can use Data Fetcher's Schedule feature to make HTTP GET requests in Airtable at specific intervals. This feature can come in handy if you're fetching match scores from the football-data API.
The Schedule feature is available on our paid plans, so follow these steps to upgrade and schedule your requests:
1. Open the request in Data Fetcher, and scroll down to the Schedule/Trigger/Webhook URL tabs. Select Schedule, and click Upgrade.
2. Select the paid plan that suits you best and complete the payment process.
3. Go back to your request in Data Fetcher and click I’ve done this under schedule.
4. Click + Authorize.
5. Click Add a Base in the window that opens. Then select All current and future bases in all current and future workspaces so you don’t need to authorize Data Fetcher anytime you want to use it.
6. Click Grant Access.
7. The schedule feature will now be turned on in Data Fetcher. Select the schedule you want, then click Save.
To recap, whenever you want to make GET requests in Airtable, using Data Fetcher:
If you're looking to save time, you can check out our guide on running cURL commands in Airtable with Data Fetcher. Data Fetcher will automatically import headers, parameters, and other request data when you run requests using cURL Commands.
Oct 7, 2024
•Zayyad Muhammad Sani
•Custom RequestsData FetcherSep 20, 2024
•Zayyad Muhammad Sani
•Custom RequestsAug 20, 2024
•Zayyad Muhammad Sani
•Custom Requests