algodex / algodex-service

@algodex/service
GNU Affero General Public License v3.0
2 stars 1 forks source link

✨ Feature: Create Orderbook API endpoints #20

Open PhearZero opened 2 years ago

PhearZero commented 2 years ago

Orderbook Display for Orderbook Component

Data from algodex-backend/orders.php?assetid=24891477 is currently aggregated in the frontend using this map function: https://github.com/algodex/algodex-react/blob/development/hooks/useAlgodex.js#L232 and displayed here in the Orderbook:

Capture

Reduce data sent to client in the <Orderbook /> Component. The component will fetch both sides of the Orderbook summary.

Orderbook Buy/Sell will be our first to include a page= and limit= query parameter. They also should optionally contain a valid Response Object for Infinite Scroll

Notes:

This should also add size filter for orderbook display. Size is the minimum amount a order can have to be displayed in the orderbook.

API Route

./public-api/orderbook.php?id={assetId}&type="buy"&page=0&limit=100&size=100

Example Response:

{
  "ok": true,
  "rows": 1,
  "offset": 0,
  "data": [{
     "price": 1234,
     "amount": 23,
     "total": 100000
  }]
}

Stretch Goals:

The reduction in API responses and separation of Business/Presentation layers gets us ready for Infinite Queries (aka Infinite Scroll). This would be subsetting the responses with pagination and adding Infinite Scroll to the components.

React-Query Docs: https://react-query.tanstack.com/guides/infinite-queries Working Example: https://react-query.tanstack.com/examples/load-more-infinite-scroll

create-issue-branch[bot] commented 2 years ago

Branch issue-112-✨_Feature_Create_Orderbook_API_endpoints created!

atrefonas commented 2 years ago

This will be done in V2 (algodex-service)