Searching for a place via Google Maps is now the way that most people find their way around, because we can simply type in the name of the place and Google’s search in does the heavy lifting of finding out more information about where exactly we mean – standing in Copenhagen, if I search for “7-Eleven”, it will show those nearest to me based on my actual location, or if that’s switched off, my IP address or the language I’m searching in, because it knows I probably don’t want to know about locations in Japan or the United States. But how is this useful in data analysis?

Often information with a geographic context (such as a list of locations that a company operates in) doesn’t come with any kind of geometry to give this context a spatial dimension – no address, no postcode, and certainly no latitude and longitude. But Google Maps’ Places API allows us to automate a set of searches based on how we might search for these places as a human, leaving their engines to do the hard work. In this blog post we’ll get started with using the Google Cloud Platform, and in the next post I’ll show you how to use an API in an Alteryx flow.

Step 1: Sign up to the Google Cloud Platform.

Google Cloud Platform is the API developer area of Google’s services, where you register as a user to obtain API keys. Sometimes the console can feel like flicking through a tsunami of information, so we’ll proceed through it slowly here.

You’ll need a Google account – if you don’t have one, set one up first. Then, visit Google Cloud Platform and click ‘Try GCP Free’, which will take you through a two step process which does involve entering your card details. The details are to secure your keys and identity (you are using a serious service!) but you’re provided with $300 of free credit for the year, which mindful use of your queries (e.g. running and caching in Alteryx, not running every time) means it should be more than sufficient.

After you’ve signed up you should be guided to a console or dashboard, which will look pretty empty!

GCP is structured so that API keys sit within ‘projects’, so create a project using the dropdown from the blue bar called ‘Select a Project’ – fill in the details and you’re all set.

If its the first time you’ve opened the console you may be guided to the API library place to find Google Maps Places API, but if not, from the dashboard select ‘Go to APIs Overview’ and then you can ‘Enable APIs and Services’.

 

Pressing ‘Enable’ will take you through to the API library, which makes it easy to find which of Google’s many services you actually need. We need Places API, at the end of the top row. SDK stands for ‘Software Development Kit’ and that’s for people who are developing full scale apps.

 

Clicking on Places API brings you to its library entry, which looks like the below. If this is your first time using it, you’ll have a different button from ‘Manage’ – Enable!

Step 2 – Obtaining the key

Once enabled, you can request and generate your key, which Google will store for you on the platform in case you misplace it. Clicking on Enable as above will lead you to another dashboard where you are looking for a tab or dialog box referring to ‘credentials’ – this is where GCP will generate your key.

Clicking on the link to credentials, or clicking ‘create new credentials in the API Manager’ will take you from the dashboard to this credentials view below.

Click on create credentials and choose the first option; the others are for applications.

A pop up will generate your API key – make a note of it!

You can edit APIs with the little pen that will appear along the line of the key – this is where you can rename it (which is good for your own sanity) and restrict it to control use and credit.

If you can, its strongly recommended that you secure the API key, so use (and therefore your credit!) can be restricted to only uses you approve of. Now you have it, you can revert to the documentation for the key to learn how to construct the query so that Places will return information about your search.  Click save and that’s it! You now how credentials to use with Google’s API. Later this week we’ll be using it to find the address and geometry of some places using a human-type query.