Skip to content
All library documents

Comparing REST and WebSocket Exchange API Response Times

Article Strategy library · Author: momox

Summary

This utility compares response times for an exchange account query using REST and WebSocket modes. It iterates through configured exchanges, makes repeated calls to the account endpoint in each mode, measures elapsed time, and logs an average for each. The tested API function can be changed, for example to a market-data query. The document advises using only exchanges with WebSocket support and notes that testing temporarily increases API call frequency.

The script offers a practical way to compare request latency in a particular setup, but it does not include measured results or a detailed test protocol. Its repeated calls are spaced by one second, and the code’s loop and averaging behavior should be checked before interpreting the reported average. Results would also depend on the exchange, network, endpoint, and runtime environment, so this small benchmark alone cannot establish general execution quality or fill performance.

Key ideas

  • The utility measures elapsed time for repeated exchange API calls in REST and WebSocket modes.
  • It logs an average response time for each mode and configured exchange.
  • The account query can be replaced with another API call for testing.
  • Only exchanges with WebSocket support can be tested in WebSocket mode.
  • The document warns that testing increases API call frequency and reports no benchmark results.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.