How to paginate through API results

I’m using the “Pull from an API” step with NationBuilder’s API which returns in this format:

{
  "results": [
    {
      post data...
    },
    {
      post data...
    },
    {
      post data...
    }
  ],
  "next": "/api/v1/sites/example/pages/blogs/6/posts?__nonce=123&__token=123",
  "prev": null
}

Reference: https://nationbuilder.com/blog_posts_api

The number of returned items exceeds the amount per page though so I’m trying to paginate through all pages but instead just keep getting that max number for a page back:

Am I right in thinking this API is using the cursor pagination style with a “Cursor key” of next? And if so, what goes in the “Cursor path in response field”?

Hey Chris!

Unfortunately that API’s pagination is not going to work with Parabola. It’s very close though!

In this case, you would put next for the “Cursor path in response field”. That field is for setting the path of the cursor. In your data, it’s in a field called next.

If the cell in the “next” column looked like this instead:

{"nextPageCursor": "abc123"}

Then you would use next.nextPageCursor to target the exact field you want.

For the Cursor Key field, you would put whatever the API uses as its pagination key - probably next as well in this case.

Cursor pagination in Parabola requires the API to send back either a Cursor Value, something like abc123 or a Full URL, something like https://my.api.com/posts?next=abc123. If your API only sends a Cursor Value, then you must provide a Cursor Key, so that it can be added to your existing API for the next call. If the API sends back a full URL, then that URL will just be used in its entirety.

The reason that this pagination style from this API will not work is because they are sending back a partial URL. Parabola cannot fetch any data from what is showing in your “next” column, as it is missing the first part of the URL. It also is not just the Cursor Value, which would be added to your existing URL to create the next call.

Because it is a part of a URL, Parabola would need to figure out how to complete it, and that is not currently supported.

Thanks Brian,

I only need to run this flow once to import data into Webflow but after that it never needs to work again. And there are only 6 pages of results total. Is there any way I can manually retrieve the results from those 6 pages in Parabola? Like is there even a way to get just that second page?

Edit: I was able to retrieve all 6 pages of results and manually stitch them together in a single JSON object. So now figuring out the easiest way to get that into Parabola for use.

1 Like

Hey Chris! One way would be to string 6 Enrich with an API steps together, using each one to fetch the next page. The problem is that it will place the next page of data side by side the other pages, so some creative parsing of that would be needed.

If you have pulled all 6 pages, and have them in a .json file, you can import that JSON file into Parabola! There is a step called Use a JSON file that will pull it in, and then you can work with it from there.

1 Like

Thanks Brian,

Yeah I have a few steps now in my flow with data looking right and mapped to Webflow collection fields:

so I tried to run the flow but ran into an error:

Failed
Today at 12:46pm EST
4s elapsed
100 max rows processed
1 run credit

Enabled Exports:
Send to Webflow
(0 rows)

Send to Webflow
Row: 1 | ValidationError: Provided ID is invalid

Screen Shot 2020-12-08 at 12.53.00 PM

Is that saying I need to buy Parabola credits to enable that Webflow export step or something else? The id column in my JSON file does have a number and is mapped to Webflow’s Item Id field so I’m not sure about that validation error at the end either.

That error is because you may be sending an ID that Webflow does not know. They keep an internal set of IDs for anything in the CMS.

If you ware trying to create new items in Webflow, then you will not need to map an ID.

That is only needed if you are updating items in Webflow. If you do want to update the items, then you have to use the ID that Webflow uses. You would pull that in with a Pull from Webflow step, and then use a combine tables step to get that data joined to your JSON data.

Ah thanks, I had inadvertently changed that setting, misreading it as referring to a collection, not collection items. Switched it back and the flow works. Thanks for your help!

1 Like