BitgetEndpointRouter

Trait BitgetEndpointRouter 

Source
pub trait BitgetEndpointRouter {
    // Required methods
    fn rest_endpoint(&self) -> &'static str;
    fn ws_endpoint(&self, endpoint_type: EndpointType) -> &str;
}
Expand description

Bitget-specific endpoint router trait.

This trait defines methods for obtaining the correct API endpoints for Bitget. Bitget uses a simple structure with separate public and private WebSocket endpoints.

§Implementation Notes

  • REST API uses a single domain for all operations
  • WebSocket has separate endpoints for public and private data
  • Testnet mode switches to completely different domains

§Sandbox/Testnet Mode

When sandbox mode is enabled (via config.sandbox or options.testnet):

  • REST URL changes to api-testnet.bitget.com
  • WebSocket URLs change to ws-testnet.bitget.com

Required Methods§

Source

fn rest_endpoint(&self) -> &'static str

Returns the REST API endpoint.

Bitget uses a single REST domain for all market types and operations. The product type (spot, umcbl, dmcbl) is specified in the API path, not in the domain.

§Returns

The REST API base URL string.

§Production vs Testnet
  • Production: https://api.bitget.com
  • Testnet: https://api-testnet.bitget.com
§Example
use ccxt_exchanges::bitget::{Bitget, BitgetEndpointRouter};
use ccxt_core::ExchangeConfig;

let bitget = Bitget::new(ExchangeConfig::default()).unwrap();
let url = bitget.rest_endpoint();
assert_eq!(url, "https://api.bitget.com");
Source

fn ws_endpoint(&self, endpoint_type: EndpointType) -> &str

Returns the WebSocket endpoint for a specific endpoint type.

Bitget uses separate WebSocket URLs for public and private data:

  • Public: /v2/ws/public - Market data (no authentication)
  • Private: /v2/ws/private - Account data (authentication required)
§Arguments
  • endpoint_type - The endpoint type (Public or Private)
§Returns

The complete WebSocket URL for the specified endpoint type.

§Production vs Testnet

Production:

  • Public: wss://ws.bitget.com/v2/ws/public
  • Private: wss://ws.bitget.com/v2/ws/private

Testnet:

  • Public: wss://ws-testnet.bitget.com/v2/ws/public
  • Private: wss://ws-testnet.bitget.com/v2/ws/private
§Example
use ccxt_exchanges::bitget::{Bitget, BitgetEndpointRouter};
use ccxt_core::types::EndpointType;
use ccxt_core::ExchangeConfig;

let bitget = Bitget::new(ExchangeConfig::default()).unwrap();

// Get WebSocket URL for public market data
let ws_public = bitget.ws_endpoint(EndpointType::Public);
assert!(ws_public.contains("/v2/ws/public"));

// Get WebSocket URL for private account data
let ws_private = bitget.ws_endpoint(EndpointType::Private);
assert!(ws_private.contains("/v2/ws/private"));

Implementors§