In this easy-to-follow guide, we'll use Data Fetcher and theĀ exchangerate.hostĀ API to import current currency exchange rates into Airtable whenever a change is made to a record in Airtable. We will also schedule the exchange rates to update on a regular schedule so we always have access to the latest figures.
We'll import currency data when a record is updated, but you can use the same approach to import stock prices, crypto prices, enrich leads or any other information.
This tutorial is 100% no code and Data Fetcher's standard features are free to use.Ā
Exchange rates API is aĀ free service offering easy access to current and historical foreign exchange rates & crypto exchange rates.
Create a new table in your Airtable base called 'Rates'. Add a Single select field with the name 'Currency'.
Add the names of any currencies you wish to convert into the 'Currency' field. This needs to be the standard currency abbreviation, e.g. BRL, GBP, EUR & CAD.
Next, add Data Fetcher to your base from the Airtable marketplace.Ā This free extension enables you to import many different types of data into Airtable.
After you have added the Data Fetcher to your Airtable base, you'll need to either create a free Data Fetcher account. You can also sign in to your existing account using the 'Have an account?' button on the bottom left of the Data Fetcher screen.
You can also sign-up to Data Fetcher with your Google account by selecting 'Continue with Google'.Ā
Select 'Create your first request' from the Data Fetcher home screen. Data Fetcher requests are used to import and export data. You can create multiple saved requests within one installation of Data Fetcher in an Airtable base.
On the create request screen, select 'exchangerate.host' for Application.
For Endpoint choose 'Convert from one currency to another'.
Give your request a name such as 'Import currency data' and click 'Save & Continue'.
Add a reference to your output table by clicking on the + button on the right-hand side of the From currency field and selecting your 'Rates' table and 'Currency' field.
Click 'Confirm'.
For To currency select the currency you wish to convert into. For this example, we are using USD.
TheĀ Response field mappingĀ modal will now open. This is how you configure how the fields from exchangerate.host will map to fields in your output table.Ā
For each imported field, you can either map it to an existing field in your output table or create a new one. You can also set the field type for each new field.
Click filter all to remove any pre-selected fields, then use theĀ Find fieldĀ search bar to easily locate the fields you want to import.
For this example, we are going to import the Rate field and map this to a new field with type Currency.
You will now see a new field in your output table called 'Rate' which has been populated with the exchange rates in USD for the specified currencies.
In order to run this request and import data when a record updated, we'll need to create an automation in Airtable and use Data Fetcher webhooks.Ā
Webhooks are a paid Data Fetcher feature, so you will need to upgrade your account. To do this, in Data Fetcher, scroll to Schedule and click 'Upgrade'.
Select a plan from the options and enter your payment details to upgrade.
Return to Data Fetcher and click 'I've done this'.
UnderĀ Schedule click '+ Authorize'.
A new window will now open and prompt you to authorize the Airtable bases you want Data Fetcher to have access to.
We recommend selecting 'All current and future bases in all current and future workspaces' to avoid any issues with unauthorized bases in the future.
Click 'Grant access'.
UnderĀ Webhook, click 'Turn on webhook for request' and copy the URL to your clipboard.
Next, click onĀ Automations at the top of the Airtable screen and then select 'When a record is updated'.
Under CONFIGURATION select your 'rates' table.
And a reference to your 'Currency field' under 'Fields'.
Then select 'Run script' from the Run actions menu.
Then paste the webhook into the Edit Script window.
Copy this script:
await fetch(`YOUR_WEBHOOK_URL?record_id=${input.config().record_id}`)
And paste it above the webhook in the script window in Airtable.
Next, replace YOUR_WEBHOOK_URL with your webhook URL.
We now want to replace input.config().record_id
with the Record Id from the trigger of the form being submitted.
Click on + Add input variable.
Add record_id into the Name box.
Then under Value choose 'Airtable record ID'.
Click 'Test' in order to Test output.
You should now see 'Test ran successfully'.
Next, turn on your Automation.
You'll now see that if you add (or edit) a record in your 'Currency' field, the figure in the 'Rate' field will be automatically updated to the current exchange rate for USD.
We can also set the 'Rate' field to update on a schedule in order to keep the exchange rates current by using Data Fetcher's scheduling feature.
Under Schedule toggle 'Schedule this request'.
You can select a schedule based on intervals of 'Minutes', 'Hours', 'Days' or 'Months'. As exchange rates are updated daily we will choose to run the request once a day. Click 'Save', and current exchange rates will automatically import into your Airtable base on a daily basis.
Jul 28, 2022
ā¢Rosie Threlfall
ā¢ClearbitWebhookFeb 20, 2022
ā¢Andy Cloke
ā¢FinanceCurrency ConversionJul 29, 2021
ā¢Andy Cloke
ā¢FinanceCurrency Conversion