Look Up Geolocation, Rating, Opening Hours in Airtable using Google Places API

Mar 8, 2022Andy Cloke

In this tutorial, we'll look up geolocation (latitude & longitude), Google Maps rating & opening hours for a list of businesses in Airtable. All you need to get started are the addresses of the businesses you want this information for. We'll then use the Data Fetcher Airtable extension to connect to the Google Places API and import this data. This tutorial is 100% no-code!

Add Business Names

Add the business names you want to look up in the 'Name' field in your Airtable table. Use the full address if you have it, separated by commas. If not, a name and city are sufficient. For example, 'Smoking Goat, London', a restaurant in London, is sufficient.

business-names-airtable.png

Add the following fields to your table:

  • A 'Single line text' field called 'Place id'.
  • A number field called 'Rating'.

In order to look up the ratings etc. for these addresses, we need to do two steps. First, we'll grab a place id from Google Places. Then we'll use this place id to look up the other information. Let's set two filtered views in order to do this.

Create a new Grid view called 'Needs place id' with the following filters:

  • 'Name' is not empty.
  • 'Place id' is empty.
needs-place-id-view.png

Create another new Grid view called 'Needs details' with the following filters:

  • 'Place id' is not empty.
  • 'Rating' is empty.
Screenshot 2022-02-14 at 12.49.35.png

Get a Google Places API Key

In order to connect to the Google Places API, we first need to get an API key in Google Cloud Console. First, you need to create a project with a linked billing account. Then, enable the Google Place API for this project. Finally, create an API key for the Google Places API.

The Google Places API is a paid API (from Google, not Data Fetcher). The costs are explained on this page. Google currently gives you $200 in free credit each month.

Install Data Fetcher

We're going to use the Data Fetcher extension to connect to the Google Places API with no-code. You can install Data Fetcher from the Airtable marketplace here.

After the extension launches, sign up for a free Data Fetcher account by entering a password and clicking 'Sign up for free'. This keeps your details, e.g. your API key, secure. Your Data Fetcher account is separate from your Airtable account.

Group 1Data Fetcher Sign Up .png

Look Up Place Id From Business Name in Airtable

The first thing we need to do is look up a place id for every business name in our table. We will then use this place id to look up further details (opening hours, Google Maps rating etc.) for each business.

On the home screen of the Data Fetcher extension, click the 'Create your first request' button.

click-create-your-first-request.png

You will land on the create request screen. Select 'Google Maps' for the Application.

google-maps-application-selected.png

Under Authorization, enter your Google Places API Key from the previous step.

google-maps-authorization-api-key.png

For Endpoint, select 'Find a place from name/address/phone number'

google-places-name-endpoint.png

Enter a Name for your request, e.g. 'Import Place Id'. Click the 'Save & Continue' button in the bottom right.

google-maps-place-from-name-save-continue.png

We want to use the values in our Airtable table's 'Name' field for the Input option in Data Fetcher. Under Input, click the + button to insert a reference to the table.

google-maps-input-add-icon.png

A modal will open where we can create the table reference. For Field, select 'Name'.

google-maps-input-reference-field.png

For Run for every record in view, select 'Needs place id'. Click 'Confirm'.

needs-place-id-reference.pnggoogle-maps-input-reference-confirm.png

The Input now has a reference to our table.

google-maps-input-reference.png

For Fields, select 'Place id'. For now, we're just going to look up the place id, as we need to use it to look up opening hours and other details.

google-maps-place-id.png

Click 'Save & Run' in the bottom right.

Screenshot 2022-02-14 at 12.45.22.png

The request will run and the Response field mapping modal will open. This is where you set which fields to import from the Google Places API and how they should map to your output table. For each Google Places 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 'Place id' is imported and mapped to the existing 'Place id' field in the Airtable table. Then click 'Save & Run'.

Screenshot 2022-02-14 at 12.43.31.png

Data Fetcher then run the request again for every record and look up the Google Places place id based on the business name. The records in the 'Needs place id' view will be updated and moved out of the filtered view.

google-maps-imported-place-ids.png

Look Up Geolocation, Rating, Opening Hours in Airtable using Google Places API

Now we will create a second request using the place ids to look up details about each business such as latitude & longitude, rating and opening hours. To do this we're going to create a second request in Data Fetcher.

Click 'Back' to return to the Data Fetcher home screen. On the home screen, Click 'Create request'.

google-maps-create-request.png

On the create request screen, for Application, again select 'Google Maps'.

google-maps-application-selected.png

Your API Key should populate automatically. If not, then add your Google Places API key from earlier.

google-maps-authorization-api-key.png

For Endpoint, select 'Find details for a place id'.

google-maps-place-details-for-place-id.png

For the Name of your request, enter 'Import Place Details'. Then click 'Save & Continue' in the bottom right.

google-maps-place-details-save-continue.png

We want to use the values in our 'Place id' Airtable field for Place id. Under Place id, click the + button to insert a reference to the table.

google-maps-place-id-add-icon.png

A modal will open where we can create the table reference. For Place id, select 'Place id'. For Run on every record in view, select 'Needs details'. Then Click 'Confirm'.

Screenshot 2022-02-14 at 12.51.07.png

Place id now has a reference to our table.

google-maps-place-id-reference.png

Select the Fields you want to import from Google Places. Most of these should be self-explanatory but note the following:

  • 'URL' is the URL of the place on Google Maps, whereas 'Website' is the URL of the actual business's website.
  • 'Rating' is the average for all Google reviews, e.g. '4.7'.
  • 'User rating total' is the number of Google reviews the business has.
  • 'Geometry' includes latitude and longitude for the business location as well as the viewport shown on Google Maps.
Screenshot 2022-02-14 at 12.22.45.png

Click 'Save & Run'.

Import the fields you want on the Response field mapping, then click 'Save & Run'.

Screenshot 2022-02-14 at 12.53.58.png

Data Fetcher will create the missing fields in the table, then run the request again and import rating, geolocation, opening hours and other fields for every business in the 'Needs details' view.

Screenshot 2022-02-14 at 12.55.36.png

Look Up Geolocation, Rating, Opening Hours Automatically

At the moment we have to manually click the 'Run' button for each request to look up the info from Google Maps. Let's combine the two requests into a sequence, so they run together.

On the Data Fetcher home screen, click the blue dropdown icon on the 'Create request' button. Then click 'Create sequence'.

create-sequence-button.png

Give the sequence a name, like 'Import Place Id & Details'.

Select 'Import Place Id' for the first request and 'Import Place Details' for the second. Then click 'Save'. We've no created a sequence that will run the 'Import Place Id' request, followed by the 'Import Place Details' request.

Import Place Id & Details sequence.png

We'll also schedule this to run automatically without us even being logged in to Airtable!

This requires a paid Data Fetcher account. Under Schedule, click 'Upgrade'.

schedule-upgrade.png

A new tab will open where you can select a plan and enter your payment details to upgrade.

data fetcher upgrade pricing plans.png

Back in the Data Fetcher extension, click 'I've done this'.

schedule-ive-done-this.png

Under Schedule click '+ Authorize'.

Schedule Data Fetcher

A window will open where you'll be prompted to authorize which Airtable bases you want Data Fetcher to have access to.

We recommended 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'.

schedule-authorize-bases.jpg

Back in Data Fetcher, you'll see Schedule this request is now toggled on.

Select how often you want the sequence to run, e.g. 'Every hour'. Click 'Save' The sequence will now run on the schedule and pull in the info from Google Places automatically.

schedule-save.png