3

In the transactions endpoint e.g.:

https://horizon-testnet.stellar.org/accounts/GAZHWW2NBPDVJ6PEEOZ2X43QV5JUDYS3XN4OWOTBR6WUACTUML2CCJLI/transactions?cursor=&limit=20&order=desc

Is there any way of knowing the total transactions count from the response? Is there any way of knowing the total pages so I can display that in the UI?

And for that matter, how do I know there is a next page. The next link is always present even if there are no records in the next page.

I'm not sure I understand how the pagination works here.

Thanks.


EDIT: From the answer I got from @Johan Stén (in his comment):

When the link to your current page is the same as the link to the next page, you're at the end. I can't explain why it's like that, I'm just telling you how it is

And digging some more:
The concept is somehow still unclear.

In the link I provided there are 39 transaction total (using limit 20 => 2 pages). but if I follow the next until current (self) == next, I'm at the 3rd page where there are no records at all.

So at page 2 I can't tell if there are no more pages...

Is this how it suppose to work? :/ should I read ahead the next block just to see if there are no more records in the next page?

1

Regarding knowing when it ends, IIRC the next next-link will be the identical to the one pointing to it when you've reached the end.

I don't think there's an easy way of finding the number of transactions of an account, except for enumerating them and counting.

  • Can you please elaborate? what do you mean by "the next next-link will be the identical to the one pointing to it"? there are the _links.next and for each record there is paging_token. what is the logic there? – zig Sep 23 '18 at 7:29
  • When the link to your current page is the same as the link to the next page, you're at the end. I can't explain why it's like that, I'm just telling you how it is. – Johan Stén Sep 23 '18 at 10:29
  • I see what you mean. however this is somehow "tricky": in the link I provided there are 39 transaction total (2 pages). but if I follow the next until current (self) == next, I'm at the 3rd page where there are no records at all. is this how it suppose to work? :/ should I read ahead the next block just to see if there are no more records in the next page? – zig Sep 23 '18 at 11:36
  • Yes, you should. – Johan Stén Sep 23 '18 at 12:34
  • That really seems a bad design IMHO – zig Sep 24 '18 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.