This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
This article is part of the CS Macro Development Series. The goal of this series is to communicate tips, tricks, and the thought process that goes into developing good, dynamic macros.
Implementing APIs into macros isn’t a difficult process, you only need to first understand macros and how they’ll interact with your API requests. In short, a macro gives you the ability to encapsulate just about any repeatable process in an Alteryx workflow as a tool. Understanding that, you only need to identify what in your API request will need to change with each row the process/request is being repeated for, and how to update this request dynamically.
With each row of your input data stream, expect to be able to use fields to reference what individual values will be – doing soin a formula tool willbuild out parts of the request that change with each record. If instead you need to update an argument of the request just once for all your records, try using an interface tool and a place-holding value. Need to update parts of a request for only certain records? You can use formula logic or the batch macro’s control parameter approach.
(the replace function exchanges spaces for + characters, the remainder of the + characters are added as literal strings to mirror the format above)
Then only updating our key remains before passing this to a Download Tool, and this will be the same for all our input rows:
Thev10.5example above is attached for reference. It is an adaptation of a more robust Google Maps Geocoder hosted on our gallery.
Please note that in order to use this macro, you must first generate a server key from the Google Developers Console. Each key has a limit of 2,500 free requests per day.Click here for more information on usage limits for the Google Maps API.
This macro demonstrates requests to Google Maps' web service API and is meant as a proof of concept only. It is not intended for production use.