Accounts API Issue

Devansh Dev
Devansh Dev Member Posts: 16
edited September 2017 in Reckon One
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

Comments

  • Nemanja
    Nemanja Member Posts: 1
    edited August 2017
    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.
  • Devansh Dev
    Devansh Dev Member Posts: 16
    edited September 2017
    ok Thanks Nemanja