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
36 changes: 34 additions & 2 deletions examples/rest_api/market/exchange_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,39 @@
from aster.rest_api import Client
from aster.lib.utils import config_logging

# --- Configuration ---
# Set the logging level to DEBUG to capture detailed information,
# including underlying HTTP requests if the 'aster' library supports it.
config_logging(logging, logging.DEBUG)

client = Client()
logging.info(client.exchange_info())
# Get a logger instance for this module
logger = logging.getLogger(__name__)

# --- Execution ---

# 1. Initialize the Aster REST API Client.
# Assuming the Client() constructor correctly handles base URLs and default configurations.
logger.info("Initializing Aster REST API client...")
try:
client = Client()

# 2. Call the public endpoint to retrieve exchange meta information.
# This usually returns supported trading pairs, tick sizes, limits, etc.
logger.info("Fetching exchange information...")
exchange_info = client.exchange_info()

# 3. Log the retrieved information.
logger.info("Exchange Info Retrieved Successfully (Partial Output):")
# Log the first 500 characters of the output to avoid overwhelming the log,
# but indicate if the output was truncated.
info_str = str(exchange_info)
if len(info_str) > 500:
logger.info(info_str[:500] + '... (Output truncated)')
else:
logger.info(info_str)

except Exception as e:
logger.error(f"Failed to execute API call or process response: {e}")

# Note: In a production environment, you would typically pass API keys/secrets
# to the Client() constructor or handle authentication separately.