MIP Logo

Using Iterative macros to pull data from APIs

This post was originally published on The Data School blog between 2018 and July 2025, before our program was renamed to MIP’s Analytics Career Accelerator. References throughout this article to “The Data School” or “DS” all refer to what is now MIP’s Analytics Career Accelerator. The program, its people, and its commitment to launching outstanding analytics careers remain the same – just under a new name.

If you are having trouble viewing this article, please report it here

Macros are a good way to automate processes in any workflow, macros are a large feature within Alteryx. With a lot of tools being macros themselves behind the scenes. Iterative macros are at its core, just a loop that continues a certain workflow until a condition is met. This condition can be stated but is usually when something returns no data. Combining this with a download tool in order to communicate with an API, you can run multiple requests with a single workflow in order to get all the data you require from a certain request.

In order to get started, you will need the usual workflow of any macro. You require an input macro, your workflow and then your output macro. With iterative macros however you will need two output feeds, one will be your actual output so the data you want to store. The other will be the link to the next set of data you want to get.

In this example workflow above, a link is inserted to an API at the beginning, it is then downloaded and parsed. The rest of the data continues on through the O output which is the data that goes on to be kept. The process occurring below is getting the next link from an API in order to continue the process again. Not always but in this example, the header included the link for the next API link so I used a quick regex to parse it out and process it to the next input. The iteration input and output have to be set in the interface designer settings. The filter used there is a good stopper in case the data doesn’t always return an empty field but sometimes what happens is it will error on the parse and instead return empty fields which will error. A null check makes sure that if it returns nothing when there is no next link to continue the loop as this is when Alteryx knows to stop.

 

Share this post