indexer.searchForTransactions().limit(10).do() is returning older transactions

Javascript indexer SDK:
when we invoke indexer.searchForTransactions().limit(10).do(),
it returns first 10 transactions instead of latest transactions.
Txns are sorted only when txns are filtered by address: indexer.searchForTransactions().address(‘hjdhsakdhkd’).limit(10).do()

How to fetch latest 10 transactions ?

This is the way the indexer is currently designed. Filtering txes by account by default reverses this order. Can you not use after-time field filter or the round?

My requirement is to show the latest 1000 transactions.
if I add filter by round and if there are no transactions after that round, then it will show an empty list.

Algoexplorer and goalseeker had their own implementations to get the latest blocks and transactions.
But I think this should be supported by indexer API’s.

Currently, that is not in the indexer API, but you could go round by round until you got the 1k or write your own query against the indexer DB.

This is not an efficient solution in the case of a local sandbox environment.
Because transactions will be very less and I end up querying more and more blocks until I get 1000 txns.

can we submit this as a requirement for the indexer team?

this is an important feature for my project.

Please +1 this issue and add a comment of your use case:

1 Like