In this guide, we'll calculate the time & distance between pairs of locations using the Google Maps API and the Data Fetcher Airtable app. This tutorial is 100% no-code. We'll create a Google Maps API key, then use it to pull in time & distance. Finally, we'll see how to schedule this to run automatically.
Install Data Fetcher from the Airtable app marketplace. After the app launches, sign up for a free Data Fetcher account by entering a password and clicking 'Sign up for free'.
On the home screen of the Data Fetcher app, click 'Create your first request'. Requests in Data Fetcher are how you import data to or send data from your Airtable base.
On the create request screen in Data Fetcher, for Application, select 'Google Maps'.
Next, enter your API Key from the previous step.
For Endpoint, select 'Calculate distance and time between start and end locations'.
Enter a Name for your request, e.g. 'Import Distance & Time'. Then click 'Save & Continue'.
We want to use the values in the 'Origin' field for Origin location. Under Origin location, click the + button to insert a reference to the table.
A modal will open where we can create the table reference. For Field, select 'Origin'.
For Run for every record in view, select 'To process'.
The Origin location now has a reference to our table.
Do the same for Destination location to create a reference to the 'Destination' field.
Select the Units for the text representation of the distance. e.g. 'Metric' to get a value expressed in km.
Optionally set the Transportation mode you want to use. If you do not set this, 'Driving' will be used.
If you selected 'Transit' for Transportation mode, you can set the type of transit (public transport) by opening 'More options for this Google Maps endpoint' and setting the Transit mode.
Click 'Save & Run'.
The request will run and the Response field mapping modal will open. This is where you set which fields to import from the Google Maps API and how they should map to your output table. For each Google Maps API field, you can either import or filter it. For an imported field, you can set whether to map them to an existing field or create a new field.
Make sure you import 'Distance', 'Distance (metres)', 'Duration' & 'Duration (seconds)'. Then click 'Save & Run'.
Data Fetcher will create any fields that need to be created in the output table, then run the request and calculate the delivery time & distance for every pair of locations in the 'Orders' table.
At the moment you have to calculate the delivery time & distance by manually clicking the 'Run' button. Let's set them to update automatically by using Data Fetcher's scheduled requests feature.
In Data Fetcher, scroll to Schedule and click 'Upgrade'.
A new tab will open where you can select a plan and enter your payment details to upgrade.
Return to the Data Fetcher app and click "I've done this".
Click 'Add API key' in order to add your Airtable API key. You can find your Airtable API key here.
Enter your Airtable API key and click 'Save'.
Enable Schedule this request.
Select how often you want the request to run, e.g. 'Every 15 mins'. Click 'Save' The request will now run on the schedule and calculate the delivery times automatically.