I Want to Get the Transactions by Reverse Order

When being getting all the transactions of an address, new transactions can arrive. The transaction move the offset and end transactions, so i want to get all the transactions from start to end.

Does API /account/transfers/incoming have options for the order.

2 Likes

I think you’d have to do that in your app/site. You’re just fetching a list of transactions, so you’d be able to sort it how you see fit once you have it.

hello,

those API endpoints all accept a id parameter which you can use to read 25 transactions before this id. Some NEM nodes also allow you querying by hash, but not all, so using the ID might be a better choice because all nodes allow that.

Basically the /account/transfers/incoming will return 25 transactions or less every time you query it. The first time, you would get the last 25 transactions with the last created (also highest ID) being the first transaction in the result set.

Next time when you query the endpoint again, you would specify the oldest ID that you got from the result set, as the id parameter to the API. Then you will get the 25 transactions or less that happened before the given transaction id.

Hope that helps!

1 Like

Thanks for the precise advice!!!!

1 Like

This is a old topic now, but for completeness, you need to know that the id parameter is node dependent - i.e. if you query the same transaction on different nodes, you can get a different id!

So if you are likely to query “pages” of transactions from a pool of nodes, then hash is the only way to get consistent results.

See my NEM Notify project as an example of how you can iterate the transactions “since” your last known offset hash.

Cheers
Rob