I had numerous trouble in setting up the googlemap Place API Key to download data using download tool in Alteryx. Hence I am writing this step by step guide, so that it would help to query quickly and easily. This blog is going to be divided into 3 parts. Firstly getting the API Key, secondly working out the Endpoint and at the end how to download the data in Alteryx.
1. Getting the API Key and enabling Place API
- First go to Google Cloud Platform Console.
- Then using your google credentials, login to the Google Cloud Platform.
- Then click “Create Project” from right hand side menu.
- It would take you to a screen to create a project.
After giving a project name click ok.
5. Next you have to select Place API in the Marketplace.
6. Click Enable in the Places API.
It will take us to the main dashboard.
7. Click the Menu in Google Cloud Platform.
8. And then API & Services -> Credentials
9. Click on API Key to get the Key.
2. How to create the Endpoint
Places API gets the data from the same database as google maps.Below is the list of information we can get from the place API.
In this blog, I am going to focus on Place Search.
The Places API lets you search for place information using a variety of categories, including establishments, prominent points of interest, and geographic locations. You can search for places either by proximity or a text string. A Place Search returns a list of places along with summary information about each place. More details can be read here. https://developers.google.com/places/web-service/search?hl=en_US
There are 3 types of search for Place search.
- Find Place Request.
A Find Place request takes a text input and returns a place. The input can be any kind of Places text data, such as a name, address, or phone number. The request must be a string. The starting of End point for this would be https://maps.googleapis.com/maps/api/place/findplacefromtext/output?parameters
2. Nearby Search request
A Nearby Search lets you search for places within a specified area. You can refine your search request by supplying keywords or specifying the type of place you are searching for. The starting of End point for this would be https://maps.googleapis.com/maps/api/place/nearbysearch/output?parameters
3. Text Search request
Text Search Service returns information about a set of places based on a string . it responds with a list of places matching the text string and any location bias that has been set. The starting of End point for this would be https://maps.googleapis.com/maps/api/place/textsearch/output?parameters
How to create a Endpoint Place Search.
There are three parts for this
- API Key
- Output type
Type of output can be either XML or Json.
Each Type has its own Required Parameter set and option parameters. Depending on your need, you can make use of these parameters. More information about the Parameters and how to output the data can be found here https://developers.google.com/places/web-service/search
For this blog I’m going to Find Restaurants in my Area with the help of Lat, Lon coordinates and Radius. This could be best approached by Text Search Request and I would like to output it in JSON format.
The Endpoint for the above scenario would be https://maps.googleapis.com/maps/api/place/textsearch/json?query=restaurant&location=33.8688,151.2093&radius=10000&key=[API Key]
The Endpoint can be divided int o 4 parts.
the first section is the URL for Text search request. The second part is the Output format as Json. Third part is the parameters, in my case it is the key word “Restaurant”, Location in Lat and Lon coordinate and the radius. And the last part is the API Key.
3.Now that we have the endpoint, how do we query it in Alteryx?
It is very simple. We have to create a text input tool to save the End Point and then connect it with the download tool.
In the download tool Connect it to the EndPoint and output it as String.
And then Click Run.
IF everything goes well, the Download header will have the following message in the results window.
The Final Output will be in the DownloadedData Coloumn in Json format.