Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,22 @@ pass `testnet=True` when creating the client.
# get a deposit address for BTC
address = client.get_deposit_address(coin='BTC')

# Error Handling
It's a best practice to handle API exceptions to prevent your app from crashing during network issues or invalid requests.

```python
from binance.exceptions import BinanceAPIException, BinanceOrderException

try:
# Example: Fetching a non-existent symbol to trigger an error
ticker = client.get_symbol_ticker(symbol="INVALID_SYMBOL")
except BinanceAPIException as e:
# Handles errors returned by the Binance API
print(f"API Error: {e.status_code} - {e.message}")
except Exception as e:
# Handles other Python related errors
print(f"An unexpected error occurred: {e}")

# get historical kline data from any date range

# fetch 1 minute klines for the last day up until now
Expand Down