Class: WebsocketAPIClient
This is a minimal Websocket API wrapper around the WebsocketClient.
Some methods support passing in a custom "wsKey". This is a reference to which WS connection should be used to transmit that message. This is only useful if you wish to use an alternative wss domain that is supported by the SDK.
Note: To use testnet, don't set the wsKey - use testnet: true in the constructor instead.
Note: You can also directly use the sendWSAPIRequest() method to make WS API calls, but some may find the below methods slightly more intuitive.
Refer to the WS API promises example for a more detailed example on using sendWSAPIRequest() directly: https://github.com/tiagosiebler/bybit-api/blob/master/examples/ws-api-raw-promises.ts
Constructors
Constructor
new WebsocketAPIClient(options?: WSClientConfigurableOptions & Partial<WSAPIClientConfigurableOptions>, logger?: object): WebsocketAPIClient;Parameters
| Parameter | Type | Description |
|---|---|---|
options? | WSClientConfigurableOptions & Partial<WSAPIClientConfigurableOptions> | - |
logger? | { error: (...params: any) => void; info: (...params: any) => void; trace: (..._params: any) => void; } | - |
logger.error? | (...params: any) => void | - |
logger.info? | (...params: any) => void | - |
logger.trace? | (..._params: any) => void | Ping/pong events and other raw messages that might be noisy. Enable this while troubleshooting. |
Returns
WebsocketAPIClient
Methods
amendOrder()
amendOrder(params: AmendOrderParamsV5): Promise<WSAPIResponse<OrderResultV5, "order.amend", {
}>>;Amend an order
Parameters
| Parameter | Type | Description |
|---|---|---|
params | AmendOrderParamsV5 | - |
Returns
Promise<WSAPIResponse<OrderResultV5, "order.amend", { }>>
batchAmendOrder()
batchAmendOrder(category: "linear" | "option", orders: BatchAmendOrderParamsV5[]): Promise<WSAPIResponse<{
list: BatchAmendOrderResultV5[];
}, "order.amend-batch", BatchOrdersRetExtInfoV5>>;Batch amend orders
Parameters
| Parameter | Type |
|---|---|
category | "linear" | "option" |
orders | BatchAmendOrderParamsV5[] |
Returns
Promise<WSAPIResponse<{ list: BatchAmendOrderResultV5[]; }, "order.amend-batch", BatchOrdersRetExtInfoV5>>
batchCancelOrder()
batchCancelOrder(category: "linear" | "option", orders: BatchCancelOrderParamsV5[]): Promise<WSAPIResponse<{
list: BatchCancelOrderResultV5[];
}, "order.cancel-batch", BatchOrdersRetExtInfoV5>>;Batch cancel orders
Parameters
| Parameter | Type |
|---|---|
category | "linear" | "option" |
orders | BatchCancelOrderParamsV5[] |
Returns
Promise<WSAPIResponse<{ list: BatchCancelOrderResultV5[]; }, "order.cancel-batch", BatchOrdersRetExtInfoV5>>
batchSubmitOrders()
batchSubmitOrders(category: "linear" | "option", orders: BatchOrderParamsV5[]): Promise<WSAPIResponse<{
list: BatchCreateOrderResultV5[];
}, "order.create-batch", BatchOrdersRetExtInfoV5>>;Batch submit orders
Parameters
| Parameter | Type |
|---|---|
category | "linear" | "option" |
orders | BatchOrderParamsV5[] |
Returns
Promise<WSAPIResponse<{ list: BatchCreateOrderResultV5[]; }, "order.create-batch", BatchOrdersRetExtInfoV5>>
cancelOrder()
cancelOrder(params: CancelOrderParamsV5): Promise<WSAPIResponse<OrderResultV5, "order.cancel", {
}>>;Cancel an order
Parameters
| Parameter | Type | Description |
|---|---|---|
params | CancelOrderParamsV5 | - |
Returns
Promise<WSAPIResponse<OrderResultV5, "order.cancel", { }>>
getWSClient()
getWSClient(): WebsocketClient;Returns
setTimeOffsetMs()
setTimeOffsetMs(newOffset: number): void;Parameters
| Parameter | Type |
|---|---|
newOffset | number |
Returns
void
submitNewOrder()
submitNewOrder(params: OrderParamsV5): Promise<WSAPIResponse<OrderResultV5, "order.create", {
}>>;Submit a new order
Parameters
| Parameter | Type | Description |
|---|---|---|
params | OrderParamsV5 | - |
Returns
Promise<WSAPIResponse<OrderResultV5, "order.create", { }>>