How do I paginate from a REST API?

Hey @StephanieBB ,

That is a great question! So for this to work properly you’ll have to build a looping systems which checks if there is a next page, and then loops the scenario.

The best way to do this in my opinion is as follows. You will have a “trigger scenario” (#1) and a “looping scenario” (#2).

  1. Create a new scenario (#1) which runs the looping scenario (#2) via webhooks . See 🤖 [Make Bot Tips] Trigger scenario run from another scenario
  2. In the loop scenario (#2), add a webhook as trigger instead of this HTTP call. The webhook will act as a trigger and will contain data for possible looping.
  3. Within the looping scenario (#2):
  • Create an if() statement within the URL section of your HTTP module. IF there is a "next page URL" from the webhook use this, otherwise use the basic URL.
  • add another HTTP call which will trigger the same looping scenario (#2) with additional parameters. Within your parameters you will add the URL of the next page.
  1. Now when you run this, it will keep triggering until there is no next URL anymore. You’ve build a loop

Hope this helps you!

3 Likes