Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateWsSignature(apiSecret, data string) string
- type ChannelType
- type Client
- type CommonResponse
- type Environment
- type PingMsg
- type PrivateChannels
- type PublicChannels
- type SoppingOptionsResponse
- type SubChannel
- type SuccessResponse
- type WSPongPrivateLinearInverseResponse
- type WSPongPrivateResponse
- type WSPongPrivateSpotResponse
- type WSPongPublicLinearInverseResponse
- type WSPongPublicResponse
- type WSPongPublicSpotResponse
Constants ¶
const ( DefaultScheme = "wss" ApiV5 = "v5" PingInterval = 30 * time.Second PingOperation = "ping" AuthOperation = "auth" ReconnectionRetries = 3 ReconnectionDelay = 10 * time.Second Public ChannelType = "public" Private ChannelType = "private" )
const ( // WSMessageText represents the message type for text in WebSocket communications. WSMessageText = websocket.TextMessage )
Variables ¶
var DefaultReqID = randomString(8)
Functions ¶
func GenerateWsSignature ¶
GenerateWsSignature generates a signature for the WebSocket API.
Types ¶
type ChannelType ¶
type ChannelType string
ChannelType defines the types of channels (public/private) that the WebSocket client can connect to.
type Client ¶ added in v0.1.6
type Client struct { Conn *websocket.Conn IsTestNet bool IsPublic bool ApiKey string ApiSecret string Channel ChannelType Path string Connected chan struct{} OnConnected func() OnConnectionError func(err error) Category string // contains filtered or unexported fields }
Client is the main WebSocket client struct, managing the connection and its state.
func NewClient ¶ added in v0.1.6
NewClient initializes a new WSClient instance. apiKey and apiSecret are required for authentication with private channels. isTestNet determines if the client connects to a test network. isPublic specifies if the client connects to a public channel.
func (*Client) Authenticate ¶ added in v0.1.6
Authenticate sends an authentication request to the WebSocket server.
func (*Client) Close ¶ added in v0.1.6
func (c *Client) Close()
Close gracefully closes the WebSocket connection.
func (*Client) Connect ¶ added in v0.1.6
Connect establishes a WebSocket connection to the server based on the configuration.
type CommonResponse ¶
type CommonResponse struct { Op string `json:"op"` // Op is the operation of the request ConnId string `json:"conn_id"` // ConnId is the connection ID of the request }
CommonResponse encapsulates fields that are common across various WebSocket responses.
type Environment ¶
type Environment string
Environment denotes the environment in which the Bybit API operates (e.g., "production", "development").
type PrivateChannels ¶ added in v0.1.6
type PrivateChannels string
PrivateChannels represents the type for private channels.
type PublicChannels ¶ added in v0.1.6
type PublicChannels string
PublicChannels represents the type for public channels.
type SoppingOptionsResponse ¶
SoppingOptionsResponse describes the sopping options with associated arguments and operations.
type SubChannel ¶
type SubChannel string
SubChannel represents a sub-channel for Bybit API's WebSocket communications.
type SuccessResponse ¶
type SuccessResponse struct { CommonResponse Success bool `json:"success"` // Success indicates the success status of the request RetMsg string `json:"ret_msg"` // RetMsg provides details on the return message of the request Op string `json:"op"` // Op is the operation of the request ConnId string `json:"conn_id"` // ConnId is the connection ID of the request }
SuccessResponse represents the response structure for a successful WebSocket request. It provides details about the operation, connection ID, success status, and return message.
type WSPongPrivateLinearInverseResponse ¶
type WSPongPrivateLinearInverseResponse WSPongPrivateResponse
WSPongPrivateLinearInverseResponse represents a specific private pong response for linear inverse operations.
type WSPongPrivateResponse ¶
type WSPongPrivateResponse struct { CommonResponse ReqId string `json:"req_id"` Args []string `json:"args"` }
WSPongPrivateResponse contains fields common to private pong responses. It also provides a unique request ID and arguments associated with the response.
type WSPongPrivateSpotResponse ¶
type WSPongPrivateSpotResponse WSPongPrivateResponse
WSPongPrivateSpotResponse represents a specific private pong response for the spot.
type WSPongPublicLinearInverseResponse ¶
type WSPongPublicLinearInverseResponse struct { WSPongPublicResponse ReqId string `json:"req_id"` }
WSPongPublicLinearInverseResponse represents a specific public pong response for linear inverse operations and also contains a unique request ID.
type WSPongPublicResponse ¶
type WSPongPublicResponse struct {
SuccessResponse
}
WSPongPublicResponse contains fields common to public pong responses.
type WSPongPublicSpotResponse ¶
type WSPongPublicSpotResponse WSPongPublicResponse
WSPongPublicSpotResponse represents a specific public pong response for the spot.