Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Google Maps API - Next Page Token

faresghnaim
7 - Meteor

Greetings guys, 

I have been using Google Maps API in my Alteryx workflow in order to get results with longitude and latitude for specific search queries, however, I am only able to get 20 results maximum per run while I am supposed to be getting 60 max.

 

I figured that the problem is that Google API shows 20 results per page and to access the next page you would have to use their next page token as seen in the picture below:

Faresghnaim_0-1571847484817.png

Unfortunately, I was not able to think of a way to add this to my workflow or my link.

If anyone is familiar or used Google API's before and was able to add this, please help!

 

Thank you so much!

7 REPLIES 7
BrandonB
Alteryx
Alteryx

You will need to leverage an iterative macro in your workflow to deal with next page tokens: https://help.alteryx.com/current/IterativeMacro.htm 

 

The iteration output will need to pass the next page token back through to the next iteration. If you aren't familiar with iterative macros you can follow along with this training video: https://community.alteryx.com/t5/Videos/Build-Your-First-Iterative-Macro/m-p/55565

BrandonB
Alteryx
Alteryx

If you need a good starting point there are also plenty of examples on the public gallery: https://gallery.alteryx.com/#!search/undefined/google%20maps 

DiganP
Alteryx Alumni (Retired)

@faresghnaim You can also create a new column with the next_page_token in it. You can then create a final url in the formula tool into a download tool. This will grab the API response per line. You can then use the json parse tool to parse the json results to grab the actual lat/long.

 

Side note - Google maps API charges per request so depending on the the amount, the cost can really add up. Depending on the size of the data, you can think about the location insights dataset Alteryx offers. 

Digan
Alteryx
BrandonB
Alteryx
Alteryx

@faresghnaim additionally, you will want to set your number of iterations to 3. The Google Maps API can respond 60 results total, but in batches of 20 at a time. Therefore, it can iterate 3 times per query to return the full 60 results.

Tyler_Rooks
6 - Meteoroid

@faresghnaim  Were you ever able to get this working.

 

I have a workflow that passes the next page token back through to rerun, but the issue I'm having is the timing (there needs to be a brief delay before the initial call and the second call with the next page token because of a lag between when the token is issued and when it becomes usable.  

 

I've tried the throttle tool to slow it down a little, but for some reason that doesn't work.

 

Would love to see you you solved this.

Cheers!

BrandonB
Alteryx
Alteryx

@Tyler_Rooks can you try adding a block until done tool after the throttle? 

Tyler_Rooks
6 - Meteoroid

Thanks @BrandonB 

 

I did try the block until done tool, but for whatever reason that didn't work.  Maybe that tool doesn't work exactly the way I thought it did as I think it was maybe still initiating the second call prematurely somehow.

 

 

Anyways, I was actually able to get this working with an iterative macro, with the throttle tool before the loop output.

Labels