The dapp I'm building can not rely on the paging mechanism described here, since after a short amount of time I will have a lot of transactions for a given account. Retrieving them all to only select a few more recent ones is very time consuming.
If I understand your question correctly, I believe you're looking for something like this:
https://horizon.stellar.org/accounts/{ACCOUNT_ID}/transactions?order=desc&limit={N}
Where ACCOUNT_ID the account public key and N is the number of transactions you want to retrieve. Also note the order is descending (&order=desc
)
See the page reference.
-
1Richard is right. If you need only the latest transactions, just use the "transactions for account" endpoint. You can retrieve up to 200 entries at a time (request with
limit
> 200 will return an error). To fetch more than 200 entries, you'll need to make a few subsequent requests using acursor
query parameter. – Orbit Lens Jul 19 '18 at 12:29 -
1It works, I unintentionally ignored some parts of documentation, so for example in JS it would be: server.transactions().forAccount(account).limit(200).order('desc').call().then( ... ); – Maxim Gaina Jul 19 '18 at 12:50
-
did you try using the .cursor(), something like:
server. transactions() .forAccount(accountId) .cursor(timestamp) ?