-
Notifications
You must be signed in to change notification settings - Fork 0
Error Handling
Igor Sazonov edited this page Mar 9, 2026
·
1 revision
The BingX Python SDK provides a set of custom exceptions to help you handle API errors gracefully. All exceptions inherit from the base BingXException.
The following diagram illustrates the exception hierarchy:
Exception
└── BingXException
├── APIException
├── AuthenticationException
├── RateLimitException
└── InsufficientBalanceException
| Exception | Description |
|---|---|
BingXException |
The base exception for all errors originating from the SDK. |
APIException |
Raised when the API returns an error code. |
AuthenticationException |
Raised for authentication errors, such as an invalid API key or secret. |
RateLimitException |
Raised when the API rate limit is exceeded. |
InsufficientBalanceException |
Raised when there is not enough balance to perform an operation. |
It is recommended to wrap your API calls in a try...except block to handle potential exceptions:
from bingx.exceptions import (
BingXException,
APIException,
AuthenticationException,
RateLimitException,
InsufficientBalanceException
)
try:
# Your API call here
balance = client.account().get_balance()
except AuthenticationException as e:
print(f"Authentication failed: {e}")
except RateLimitException as e:
print(f"Rate limit exceeded: {e}")
except InsufficientBalanceException as e:
print(f"Insufficient balance: {e}")
except APIException as e:
print(f"API error: {e}")
except BingXException as e:
print(f"An unexpected error occurred: {e}")By handling these exceptions, you can build more resilient applications that can gracefully recover from API errors.