Jump to content
  • 0

API Pagination


SteveA
 Share

Question

Hi,  

So i've got an API call working (table\records), but i'm wondering from the results, how do you know how many pages I need to loop through to get all the results from a table?  currenlty i've got 950 rows so this could change to over 1000 quickly, just wanted to know how best to handle it.  

Any suggestions? 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

I just double checked https://acctid.caspio.com/rest/swagger#/Tables and total records returned in not included in API responses.

Try running loops until a response with no results is returned.



For example if you have 950 records...

https://acctid.caspio.com/rest/v2/tables/tbl_customer/records?q.select=PK_ID&q.pageNumber=1&q.pageSize=1000

may return

{
  "Result": [
    {
      "PK_ID": 1
    },
    * 949 more results
  ]
}


then

https://acctid.caspio.com/rest/v2/tables/tbl_customer/records?q.select=PK_ID&q.pageNumber=2&q.pageSize=1000

would return

{
  "Result": []
}

 

So when Result.length < 1, you've reached the end.

I hope this helps

Edited by LWSChad
clarity
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...