Bold Advanced v1 pagination

Hello, I can use some assistance with setting up pagination to access the Bold Advanced v1 subscriptions API. The subscription API documentation states (Bold v1 subscription docs):

GET /api/third_party/v2/subscriptions?shop={myshopifyDomain}&since_id={since_id}

This endpoint retrieves a filtered page of the store's subscriptions. This endpoint is paginated, returning a page with 50 results. To retrieve the next page of results use the greatest subscription id in a subsequent request.

So, in order to paginate I need to populate the since_id parameter with the last subscription id for each API call. Below is the API response body from the above call (since_id would either be empty or 0 for the first call):

{
"subscriptions": [
{
"id": 1122334,
"shopify_customer_id": 9876543210123,
"interval_number": 1,
"interval_type_id": 3,
"first_name": "Aaron",
"last_name": "Test",
"customer_email": "a.test@example.com",
},
{
"id": 1122345,
"shopify_customer_id": 9876543210234,
"interval_number": 1,
"interval_type_id": 3,
"first_name": "Bill",
"last_name": "Person",
"customer_email": "b.person@example.com",
},
{
"id": 1122456,
"shopify_customer_id": 9876543210345,
"interval_number": 1,
"interval_type_id": 3,
"first_name": "Peter",
"last_name": "Bilt",
"customer_email": "p.bilt@example.com",
},

....

{
"id": 1122567,
"shopify_customer_id": 9876543210456,
"interval_number": 5,
"interval_type_id": 3,
"first_name": "Jonathan",
"last_name": "Seagull",
"customer_email": "j.seagull@example.com",
},
{
"id": 1122678,
"shopify_customer_id": 9876543210567,
"interval_number": 5,
"interval_type_id": 3,
"first_name": "Test",
"last_name": "User",
"customer_email": "t.user@example.com",
}
]
}


There is nothing in the response body that tells me anything about how many records there are, how to paginate, etc. As the consumer we're supposed to simply grab the last subscription id in the array and pass it to the since_id param in the next API call.

My question is how do we do this within integrator? I have tried a few approaches, the following is the closest I've gotten to getting something to work:

In the Relative URI builder I've compared @index to '4' because in my test there are only 5 entries, but I would set this to 49 if this were to pull the entire page of 50 subs. So, this is difficult because a) it's not really working for subsequent calls (it's not paging, I'm only pulling the first 50 subs) and b) we never know how many subs there may be so there's no way to know how many the last page may contain and, if the last page has less than 50 sub records, it will always fail on the last page and/or return the first page since the value of since_id would be empty. Testing in my dev env I'm only ever pulling the first 50 subs, it doesn't appear to be making any subsequent calls, and we have around 280 subs so the last page would be less than 50 (the next call would have an empty since_id param and I'd get the first 50 subs again).

I'm really scratching my head on this. I would like to use integrator to schedule and pull this data and not have to write a custom loader to do this for me.

Any help would be appreciated! Thanks!

@bryancarroll I'm not seeing docs for the v2 endpoint, but I noticed the v1 endpoint has a next page cursor. Are you able to use v1 for this or need v2 In the meantime? I'll also play around a bit to see if I can come up with a solution here. Since I can't find the v2 docs, do you know if that endpoint has a way to sort the results?

@bryancarroll the reason I ask if you can sort is we have an object available for last record within the response. So assuming it's sorted, then you can utilize that for subsequent calls. You would need to set your "Path to records in HTTP response body" under "non-standard api response paterns" to "subscriptions".

Hey @tylerlamparter, thanks for the quick reply. You need to use the v1 docs, https://developer.boldcommerce.com/default/guides/archive/subscriptions_v1_integration#subscriptions. The endpoint URI in my submission references v2 of the thirdparty endpoint, but we're using v1 of the Bold Advanced API. The v1 docs are buried in their developer portal and I'm sure you're looking at the v2 version. There is no pagination offered in the v1 platform outside of the since_id url param.

re: sorting: from what I've seen the results consistently come back sorted by id so the last id in the collection should have the greatest integer id.

@bryancarroll in that case it sounds like the last_record path would work for you. Let me know how it goes.