if 'code' in response and response['code'] == '200':
return response['data']['spot']['list']
else:
print("Error in getting account balance:", response)
return None
def main():
Read API key and secret key from the user
API_KEY='my api key is pasted here'
SECRET_KEY='my secret key pasted here'
# Get account balance
account_balance = get_account_balance(API_KEY, SECRET_KEY)
if account_balance:
print("Account Balance:")
for balance in account_balance:
asset = balance['currency']
free_balance = balance['available']
locked_balance = balance['frozen']
print(f"{asset}: Free={free_balance}, Locked={locked_balance}")
else:
print("Failed to retrieve account balance.")
Below is the code am having isue executing having pasted my API KEY and the SECRET KEY:
import time import requests import hashlib import hmac
def create_signed_request(api_key, secret_key, method, endpoint, params={}): base_url = 'https://www.mexc.com' request_url = f"{base_url}{endpoint}" timestamp = int(time.time() * 1000) params['api_key'] = api_key params['req_time'] = timestamp sorted_params = sorted(params.items()) query_string = "&".join([f"{k}={v}" for k, v in sorted_params])
def get_account_balance(api_key, secret_key): endpoint = '/open/api/v2/account/info' method = 'GET' response = create_signed_request(api_key, secret_key, method, endpoint)
def main():
Read API key and secret key from the user
if name == "main": main()