0

I was reading the documentation page about the /orders endpoint and couldn't find how they are sorted. It's not clear how to avoid requesting all pages to get new orders.

1 Answer 1

2

The endpoint is paginated and by default it returns page 1 with 20 orders. You can for instance change this behaviour setting the param page and perPage on the query: An example of fetching on page 2 a total of 50 orders https://api.0x.org/orderbook/v1/orders?makerToken=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2&page=2&perPage=50 .

If you like to inspect code, here you can check the handler that is called by that endpoint: https://github.com/0xProject/0x-api/blob/63fd378c3fd198fd1760cd684763956defccfb55/src/handlers/sra_handlers.ts#L49 as you can see you can pass page and perPage on the query, and filter by any field that the order supports. Looking at code, it seems it is not sorted.

1
  • it's a pity they didn't implement sorting. it's much to fetch new orders because of it. Jul 12, 2022 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.