Interface comparison
The ALOR Broker trading system provides several interaction interfaces: HTTP API, WebSocket API, and GraphQL API. Each implements a different data processing model and is designed to address a specific class of tasks.
This section describes the selection criteria and typical use cases for the interfaces.
Interface Features
Each interface has its own advantages and disadvantages, which affect how effectively it can address specific tasks. To help you determine the most suitable option, the key characteristics of each interface are summarized in the table below.
| Criterion | HTTP API | WebSocket API | GraphQL API | | -------------------------- | ------------------------------ | ---------------- -------------- | -------------------------------- | | Data delivery model | Pull (request–response) | Push (message stream) | Pull (request–response) | | Data refresh mode | On demand | Real-time | On demand | | Latency requirements | Non-critical | Critical | Non-critical | | Workload type | Batch | Stream | Mixed | | Connection | Short-lived | Persistent | Short-lived | | Connection state | Stateless | Stateful | Stateless | | Interaction frequency | Low / medium | High | Low / Medium | | Data volume per query | Large | Incremental | Controllable | | Response structure | Fixed | Depends on subscription | Determined by query | | Data composition control | No | No | Yes | | Data aggregation | No | No | Yes | | Event subscription | No | Yes | No | | Number of queries | Can be high | Reduced by subscriptions | Reduced by aggregation | | Client requirements | Minimal | Increased (stream processing) | Average | | Typical scenarios | History, reference data, operations | Market data, events | Aggregated samples |
Selection Algorithm
The sequence of interface selection for solving the task can be simplified using the diagram below.
Typical Use Cases
The typical API use cases listed below should be used as a reference when designing your integration. If your use case does not match any of the scenarios, apply the selection criteria described above.
| Scenario | Interface | Reason |
|---|---|---|
| Retrieving current quotes | WebSocket | Data changes continuously; updates must be received without delay |
| Retrieving historical candlesticks | HTTP | Data for a specific period must be retrieved in a single request |
| Retrieving the order book | WebSocket | The order book is updated in real time |
| Retrieving the instrument directory | HTTP / GraphQL | Large data volume, infrequent changes |
| Retrieving extended instrument information | GraphQL | Requires aggregating data and selecting specific fields |
| Placing a single order | HTTP | Atomic operation in a request-response model |
| Massive, high-volume order submission | WebSocket | A high frequency of command transmission and asynchronous receipt of processing results are required, without the overhead associated with establishing connections |
| One-time retrieval of order status | HTTP | A single request is sufficient |
| Tracking order status changes | WebSocket | Requires real-time status updates |
| Tracking transactions | WebSocket | Transactions are received as a stream of events |
| Retrieving portfolio status | HTTP | Requires a one-time snapshot of the status |
| Tracking portfolio changes | WebSocket | Changes occur asynchronously |
| Retrieving transaction history | HTTP | Requires a sample for a specific period |
| Retrieving aggregated portfolio information | GraphQL | Requires combining multiple entities |
Sometimes the same action can be performed using different interfaces. In this case, you should choose an interface based on how often and intensively you perform that action.
For example, you can retrieve the status of a request via both the HTTP API and the WebSocket API. The difference is that the first interface will return the status at the time the request is made, while the second will transmit all changes in real time.
For maximum efficiency, combine the available interfaces. For example, by requesting historical data via the HTTP API and monitoring the order book in real time via WebSocket, you’ll get a complete overview of the instrument’s price changes before purchasing it.
Using the interface for purposes other than its intended use may result in access to the system being blocked.