Loop Over Items : “done” branch triggered too early when iterating paginated API

Describe the problem/error/question

I am building a n8n workflow which queries the Viator API to fetch all attractions for a destination.

This API is paginated and limited to 30 results per page.

The pagination must be specified in the JSON body of the HTTP request, for example:

{
    "destinationId": 522,
    "pagination": {
        "start": 1,
        "count": 30
    },
    "sorting": {
        "sort": "DEFAULT"
    }
}

It seems that the integrated pagination option of the HTTP Request node cannot be used in this case because the format is too specific.

So I set up the following workflow:

  • Loop indexes (Loop Over Items - Split in Batches) to generate {start, count} values for each page

  • HTTP Request to call the Viator API with these values

  • Json to Table to split the attractions array into individual items

  • Loop attractions (Loop Over Items - Split in Batches) to process each attraction and call our API to insert it into our database

The issue:

Everything works well for the first page. But starting from the second page, the “done” branch of the “Loop attractions” node is immediately triggered, and the attractions of the new page are not processed.

Everything works well for the first page, but for the second page, the “done” branch of the “Loop attractions” node is immediately triggered.

Question:

What should I change in my workflow so that the “Loop attractions” node executes properly for each page (instead of skipping directly to “done”)?

Thanks in advance.

My workflow

Information on your n8n setup

  • n8n version: 1.107.4
  • Running n8n via Docker (Kubernetes)
  • Operating system: Linux

It usually happens when one of the node didn’t have output.

So the loop will pass to done.

Check the execution to see if there is any node didn’t output anything.

Can you share a screenshot of the skipping of the execution?

Hello @ps_geolives , I see you’re having problem with getting all data because of pagination from Viator API.I tried getting Viator API key to try out the workflow below to show how to make use of the pagination feature from HTTP Request node but no success getting it.

The workflow screenshot below is just to guide you on achieving your goal and I also add resources that might help from n8n documentation. It basically get the whole results using HTTP Request pagination feature and then passing it into Split out node to get individual result.