-
Notifications
You must be signed in to change notification settings - Fork 0
Authentication
Authenticating your application is a critical first step for interacting with the BingX API. This guide provides a comprehensive overview of how to securely obtain and use your API credentials with the BingX Python SDK.
To begin, you must generate an API key and secret key from your BingX account. These keys are used to sign and authenticate your API requests, ensuring that only authorized applications can access your account.
- Log in to your BingX account and navigate to the API Management section.
- Click on the "Create API" button and follow the prompts to configure your new API key.
- During this process, you will be presented with your API Key and Secret Key. It is crucial to store these credentials in a secure location, as the Secret Key will only be displayed once.
Once you have your API keys, you can initialize the BingXClient. The client will automatically handle the signing of your requests, so you can focus on building your application.
from bingx import BingXClient
# Initialize the client with your API credentials
client = BingXClient(
api_key="YOUR_API_KEY",
api_secret="YOUR_API_SECRET"
)Replace YOUR_API_KEY and YOUR_API_SECRET with the credentials you obtained in the previous step. For more advanced configuration options, please refer to the Client Initialization guide.
Properly securing your API keys is essential to protect your account and assets. The following table outlines key security practices we strongly recommend you follow.
| Practice | Description |
|---|---|
| Secure Storage | Never hardcode your API keys in your source code or commit them to version control. Use environment variables or a secure secret management system to store your keys. |
| Principle of Least Privilege | When creating your API key, grant only the permissions necessary for your application to function. For example, if your application only needs to read market data, do not enable trading or withdrawal permissions. |
| IP Whitelisting | For an added layer of security, you can restrict API access to a specific set of IP addresses. This can be configured in the API Management section of your BingX account. |
| Regular Audits | Periodically review your API keys and their permissions to ensure they are still required and have not been compromised. |