API usage limits calculation

Hello Team

I have a Dash app wherein I am using multiple APIs like OHLC market quote, Market Feed websocket, Place Order, Modify Order, Order History, etc… From the documentation, I understand two things:

  1. Non-websocket usage: API Request Limit is 25 requests per second, 250 per minute, etc… and,
  2. Websocket usage: Stream limit: 100 instruments per connection…

I am trying to create an API usage calculator for my app… In this regard, I have following questions:

  1. Non-websocket usage: the request structure is specific to each APIs: for instance, the OHLC market quote is where one can specify multiple instruments in a single API call, whereas in the orders history API, one needs to use the API for every order ID… In such a scenario, how do we define a count of request?
  2. Web-socket usage: I assume that this limit is over and above the API request limit (25 per second and so on…), please correct if my understanding is correct…
  3. Just as a peripheral question, is there a way to discretize the connection to the websocket, may be get a feed every 5 seconds or so… I tried inserting await.sleep(5) inside the example code, but it does not seem to work…

Thanks
Ankush

Hello @Ankush_Agarwal let me try to answer your questions

  • The rate limiting is API-specific. This means you can place 20 orders per second using the place order API and make 20 calls to the historical API within the same second without encountering a rate limit, even if you make 40 API calls per second. Therefore, counting requests is straightforward from the user side.

  • I didn’t quite understand your question, but with WebSockets, you don’t have to worry about rate limits, and you can subscribe to up to 100 instrument keys.

  • Currently, there isn’t a way to instruct WebSockets to send a message response after a specific time. A simple way to implement this logic would be to store the message feed from the WebSocket in an array and have another function read the last element of the array every 5 seconds. If you want to save memory you can just store the latest 2,3 messages from the websocket feed locally and use that data every 5 seconds.

Thank you.