HTTP Request Pagination When Complete Response

I am new to this, so sorry if this is simple!

I have an API that has the following request \ response structure. I am using the new pagination options in HTTP Request (which is fantastic!) using the offset as needed. I just need to try to figure out with the response, how to identify when pagination is complete = eg the data_count equals the data_total response.

Request JSON (with pagination parameters)

{
	"region": "your_region_here",
	"api_key": "your_api_key_here",
	"data_offset": 100,
	"data_limit": 25
}

Response JSON

{
	"success": "true",
	"data": [
		100-125 results
	],
	"data_offset": 100,
	"data_limit": 25,
	"data_count": 25,
	"data_total": 550,
	"message": ""
}

Thanks so much for your help in advance.

Hey @Damien_Kelly,

Welcome to the community :raised_hands:

What does the data field output if there are no items left to fetch? As a quick test you could start the data offset as 550 to see what happens.

Hi Jon,

Thanks for getting back to me, I am sorry if this is simple! This is the response, it just appears blank i think?

image

Hey @Damien_Kelly,

For the expression to detect if empty try using something like {{ $response.body.data.length === 0 }}

Fantastic, thanks so much for your help.

@Damien_Kelly there are no silly questions when we’re learning something new :slight_smile: Likely others will have a similar question in future and can find the answer faster, thanks to you!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.