Skip to content

Client Initialization

Igor Sazonov edited this page Mar 9, 2026 · 1 revision

The BingXClient is the cornerstone of the BingX Python SDK, serving as the primary interface for all interactions with the BingX API. Proper initialization and configuration of the client are essential for the successful operation of your application.

Basic Initialization

To get started, you can initialize the client with your API key and secret. This is the simplest way to create a client instance with default settings.

from bingx import BingXClient

# Basic client initialization
client = BingXClient(
    api_key="YOUR_API_KEY",
    api_secret="YOUR_API_SECRET"
)

This configuration is suitable for most common use cases and will allow you to start making API calls immediately.

Advanced Configuration

For more advanced scenarios, the BingXClient constructor accepts several optional parameters that allow you to customize its behavior. The following table provides a detailed overview of these parameters.

Parameter Type Default Description
api_key str Required Your unique BingX API key.
api_secret str Required Your BingX API secret for signing requests.
base_uri str https://open-api.bingx.com The base URI for the API endpoints. You can change this to target different environments, such as a testnet.
source_key Optional[str] None An optional source key for tracking and analytics purposes.
signature_encoding str base64 The encoding method for the request signature. This can be set to either base64 or hex.
timeout int 30 The request timeout in seconds. This determines how long the client will wait for a response from the API.

Example of Advanced Initialization

Here is an example of how to initialize the client with custom settings for a testing environment:

# Advanced client initialization
client = BingXClient(
    api_key="YOUR_API_KEY",
    api_secret="YOUR_API_SECRET",
    base_uri="https://open-api-vst.bingx.com",  # Using the testnet endpoint
    signature_encoding="hex",
    timeout=60  # Increased timeout for potentially slower testnet responses
)

The Underlying HTTP Client

Behind the scenes, the BingXClient instantiates a BaseHTTPClient that manages all low-level HTTP requests. This client is responsible for signing requests, handling authentication, and processing API responses. While you typically do not need to interact with the BaseHTTPClient directly, it is accessible via the client.get_http_client() method for advanced use cases that require custom request handling.

Clone this wiki locally