Hi I am having an issue adding a limit query parameter to my request of List Accounts.
Here is my code.
Any ideas would be hugely welcomed.
def acc_bal(cur):
timestamp = str(int(time.time()))
method = "GET"
request_path = f'/api/v3/brokerage/accounts/?limit=250' # Added the limit parameter
body = ''
message = str(timestamp) + method + request_path + body
signature = hmac.new(secret_key.encode('utf-8'), message.encode('utf-8'), hashlib.sha256).hexdigest()
headers = {
'accept': 'application/json',
'CB-ACCESS-KEY': api_key,
'CB-ACCESS-TIMESTAMP': timestamp,
'CB-ACCESS-SIGN': signature,
'Content-Type': 'application/json'
}
conn = http.client.HTTPSConnection("api.coinbase.com")
payload = ''
conn.request("GET", request_path, payload, headers)
res = conn.getresponse()
if res.status == 200:
data = res.read().decode('utf-8')
acc_data = json.loads(data)
for account in acc_data['accounts']:
if account['currency'] == cur:
ava_bal = account['available_balance']['amount']
return ava_bal
else:
print(f"Error: Status Code {res.status}")
print(f"Response: {res.read().decode('utf-8')}")