Sort order for getTokenTransfers()

It seems like getTokenTransfers() and getTransactions() both return results in reverse chronological order. Is that always the case - can I count on this behavior? Or is the order sometimes different?


I am not sure about it myself, maybe devs can give input on you for this, but if you don’t know, best for you to do a sorting if you need to since there’s no harm doing so.

1 Like

you can count on that order for now, the idea is that if there are 100k items, you don’t have to iterate on all the pages to get the newest information. It can help when you want to process only what changed since you processed it last time.

“For now” sounds a little scary because we are building apps that will go into production. If you guys change the order, can you give people some advance notice?

If we can count on this order, can you put this in the docs?

We can put it in the docs, can you give an example for the exact query that you use?

Thanks. If the sort order on results coming back from getTokenTransfers() and getTransactions() is always reverse chronological, why does my exact query matter?

Just to know what to test before adding to documentation

Test that the sort order on the results is reverse chronological… Should work on any query.

there is this update in changeling on discord:

  NFT transfer endpoints are automatically order by timestamp descending.
  Cursor based pagination is now supported for those endpoints
       - getNFTTransfersByBlock /block/{block_number_or_hash}/nft/transfers
       - getNftTransfersFromToBlock /nft/transfers
       - getNFTTransfers /{address}/nft/transfers
       - getContractNFTTransfers /nft/{address}/transfers
       - getWalletTokenIdTransfers /nft/{address}/{token_id}/transfers