Forum Academy Marketplace Showcase Pricing Features

Paginated API Response - Extracting a URL

Hey there,

I’m currently working with the Shopify API and trying to handle paginated responses from their API.

I think I need to extract the second URL in the below example to make the next call in the series…

"link": "<https://userloop-development.myshopify.com/admin/api/2021-07/orders.json?limit=10&page_info=eyJkaXJlY3Rpb24iOiJwcmV2Iiwic3RhdHVzIjoiYW55IiwibGFzdF9pZCI6NDI4MTgzODk2MDgxNywibGFYWx1ZSI6IjIwMjEtMTItMDcgMTE6MTk6NDguOTczMTYzIn0>; rel=\"previous\", <https://userloop-development.myshopify.com/admin/api/2021-07/orders.json?limit=10&page_info=eyJk3Rpb24iOiJuZXh0Iiwic3RhdHVzIjoiYW55IiwibGFzdF9pZCI6NDI2MDU2NDc5NTU2OSwibGFzdF92YWx1ZSI6IjIwMjEtMTEtMjMgMTY6MTU6NTYuMzY5NzkzIn0>; rel=\"next\"",

Does anyone have any idea how I could extract the second URL in that block, perhaps something using regex?

I am a bit stuck with it at the moment!

Thanks, James.

What you will need to do is to have an api get with an empty url except a parameters like [url] that you will use to replace by the Next url. You need to use the same API Call for the initial load of the list and other API Call for getting next page. Also, there’s a lot of API that on the first list payload will not have the previous url. I think for shopify, this info is returned in header. So better to call the second page and be sure you have both a previous and a next page

In case anyone is looking for this in the future, I figured out how to loop the API requests from Shopify.

First you need to take the response from the first API call’s header and get the ‘link’ value.

Then you use the Bubble ‘Split by’ function to split the next/previous url links and select, last option.

Then you use find/replace to remove the fluff from the URL and call that URL to get the next page of the response

Cheers, James.

2 Likes