Pagination allows to filter using by timestamp OR id.
Paginated items could have the same timestamp, ie. trades. Several trades can occur at the same time (same timestamp) but they will have different ids.
ie: curl -X GET "https://api.hitbtc.com/api/2/public/trades/ETHBTC?sort=DESC&by=timestamp&from=2018-02-07T01%3A03%3A00.000Z&till=2018-02-07%2001%3A03%3A15%2B00%3A00&limit=2" -H "accept: application/json"
This command will return the elements in random order, as by=timestamp
So if you are paginating trades and the last element of the page is one of those trades, the next page you will get using offset will return a random element (185248983 or 185248982). Which leads to a wrong behaviour.
This issue is easily fixable using a database sorting by timestamp AND id. I'd suggest to allow to sort by more than one field.
ie:
curl -X GET "https://api.hitbtc.com/api/2/public/trades/ETHBTC?sort=DESC&by=timestamp&from=2018-02-07T01%3A03%3A00.000Z&till=2018-02-07%2001%3A03%3A15%2B00%3A00&limit=2" -H "accept: application/json"
[ { "id": 185248983, "price": "0.102005", "quantity": "0.280", "side": "sell", "timestamp": "2018-02-07T01:03:13.646Z" }, { "id": 185248982, "price": "0.102006", "quantity": "0.030", "side": "sell", "timestamp": "2018-02-07T01:03:13.646Z" } ]
This command will return the elements in random order, as by=timestamp
So if you are paginating trades and the last element of the page is one of those trades, the next page you will get using offset will return a random element (185248983 or 185248982). Which leads to a wrong behaviour.
This issue is easily fixable using a database sorting by timestamp AND id. I'd suggest to allow to sort by more than one field.
Please also check another pagination issue I found https://github.com/hitbtc-com/hitbtc-api/issues/124
Thanks!