Getting paged results from APIs (Iterative Macros)
Working with paginated results adds an extra complication to our work. We must repeat certain operations while there are still results to be received. Although there are no loop-type structures in Alteryx (while
, until
, and so on), we do have a way to solve it. To do this, we will use Iterative Macros.
An Iterative Macro is a type of macro that runs a specified number of times or until a defined condition is met for all records. Every execution of the macro is identified by a zero-index (when its value is zero, it means it’s the first iteration) internal variable called [Engine.IterationNumber]
.
In basic terms, the process of an Iterative Macro goes like this:
- It ingests all incoming data
- It processes the records
- It evaluates if a condition is met and splits the records
- For those records that met the condition, it outputs them as results
- For those that have not met the condition, it feeds them again...