Accounts API Issue

  • 1
  • Question
  • Updated 1 year ago
  • Answered
  • (Edited)
I am fetching accounts from my cashbook. I found i have total 100 accounts in cashbook, but API returns 50 accounts. Please help me. What i am missing ?

Using below API :

https://api.reckon.com/R1/{Cashbook Id}/accounts
Photo of Devansh Dev

Devansh Dev

  • 220 Points 100 badge 2x thumb

Posted 1 year ago

  • 1
Photo of Nemanja

Nemanja

  • 60 Points
All listy things like accounts, items, contacts, etc, return 50 records at a time, so you'll need to use pagination to get all your accounts. Reckon One API uses OData for that.

Since each request will get you next 50 records, you can stop once you get back less then 50 records, or you can keep making requests until you get back an empty array.

To get your 100 accounts, you'll want to make these 3 requests:
https://api.reckon.com/R1/{Cashbook Id}/accounts?$orderby=Name&$skip=0

https://api.reckon.com/R1/{Cashbook Id}/accounts?$orderby=Name&$skip=50

https://api.reckon.com/R1/{Cashbook Id}/accounts?$orderby=Name&$skip=100
Notice the $skip parameter at the end. You'll want to increase that for each subsequent request to get next 50 accounts.

Since you have exactly 100 accounts, you won't know after 2nd request if there are more accounts or not, so you have to make the 3rd request as well, even if it'll return an empty array in this case.

While $orderby=Name is not necessary, I found it easier to debug things that way, but you can omit that if you don't want your accounts sorted.
Photo of Devansh Dev

Devansh Dev

  • 220 Points 100 badge 2x thumb
ok Thanks Nemanja