Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

GeoCodio Batch API / Macro

EW
11 - Bolide

I've been using GeoCodio's API to geocode addresses in Alteryx.  I've even made a little macro for it, even though I'm fairly new at both Alteryx macros and APIs.  It works so far, but I'd like to speed it up by switching to the batch address API.  

 

I'm not sure how to format the URL in Alteryx to include multiple addresses.  I've been trying to figure it out from the GeoCodio Documentation and Googling but I haven't made headway so far.  I'm very much a beginner with using APIs.

 

Is anyone else using GeoCodio's batch geocoding API in Alteryx successfully?  Or familiar enough in general to point me in the right direction?  Any help is greatly appreciated!  

 

I'm attaching my single address URL macro for the GeoCodio API.  Note that it requires an API key to use, which are free for their starter tier.  Below is the macro workflow with the single address API URL shown.

 

GeoCodio API with Formula.PNG

14 REPLIES 14
hellyars
13 - Pulsar

@EW  Take this with a grain of salt (I know nothing about APIs or POST requests), but I had some success using the API Batch Geocoding instructions and specifically the Jason Array example. 


I used two fields  URL and Data.  

In the Download tool under the Basic tab I set URL to URL and under the Payload tab I set Action to POST and set the tool to take the values from my Data field.

 

https://api.geocod.io/v1.7/geocode?q=1109+N+Highland+St%2c+Arlington+VA&fields=cd117&api_key=Your_API_KEY
curl -X POST \
  -H "Content-Type: application/json" \
  -d '["1109 N Highland St, Arlington VA", "525 University Ave, Toronto, ON, Canada", "4410 S Highway 17 92, Casselberry FL", "15000 NE 24th Street, Redmond WA", "17015 Walnut Grove Drive, Morgan Hill CA"]' \
  https://api.geocod.io/v1.7/geocode?api_key=YOUR_API_KEY

 

This generated a positive result.  It was not perfect, but it seems to be a step in the right direction.  I think the key is in the construct of the URL request.  I had better results running a few of my own test addresses and field requests (e.g. Congressional Districts cd117).

 

 

 

hellyars
13 - Pulsar

take the &fields=cd117 out to remove the Congressional District request

hellyars
13 - Pulsar

@EW   

@BrandonB 

 

This works.  The workflow transmits the query address and receives, parses, and cleans the results.  

See Brandon's explanation for how to setup the Download tool here.

The workflow uses the JSON Array sample data from GeoCod.io's Batch Addresses example.  It is added to the Download Tool's Payload tab - per Brandon's instructions.

Swap out Your_API_Key with your real API key at the end of the URL field in the Text Input tool.

 

I hope this helps.

 

 

GeoCode_BatchAddresses.png

hellyars
13 - Pulsar

@EW  So far the solution works great for me.

 

I added a few tools that concatenate the addresses into a simple JSON array.  You can then point the Payload tab to this field instead of cutting and pasting.

GeoCode_Update1.png

 

Step 1.  Addresses start in Field1.

 

Step 2.  Use a Formula Tool to add a quote at the front and beginning of each Address record.  '"'+[Address]+'"'

 

GeoCode_Update2.png

 

Step 3.  Use a Summarize Tool to  Concatenate the Address field.  Set Start to [  Set Separator to ,  Set End to ].

GeoCode_Update3.png

 

Step 4.  In my workflow I append the Concatenated Address field to the URL field. See first image above.

 

 

Step 5.  Set Payload to Take Query String/Body/ from Field = Address

GeoCode_Update4.png

 

 

 

 

EW
11 - Bolide

Yes!!  @hellyars thank you so much - this seems to be working great!  

Labels