Hi Maksym
Trying to do an updateComboBot through python and running into issues
Same issue with swagger UI too
I want to update the DCA orders step
Using this a payload { "settings": {"step": "3.0"} }
Adding the code below. Do you see where I am messing it up?
# === Clone parameters ===
bot_id = '68ef06832306d92d3be528ce'
# === Timestamp ===
timestamp = str(int(time.time() * 1000))
# === Payload ===
payload = { 'settings': {'step': '3.0'} }
body_str = json.dumps(payload, separators=(',', ':'), sort_keys=True)
# === Endpoint ===
endpoint = f"/api/updateComboBot?botId={bot_id}&paperContext=false"
url = f"https://api.gainium.io{endpoint}"
# === Signature ===
prehash_string = f"{body_str}POST{endpoint}{timestamp}"
signature = HMAC(api_secret.encode('utf-8'), prehash_string.encode('utf-8'), sha256).digest()
signature_encoded = base64.b64encode(signature).decode('utf-8')
# === Shared headers ===
headers = {
"accept": "application/json",
"Content-Type": "application/json",
"token": api_token,
"time": timestamp,
"signature": signature_encoded
}
# === Send with requests ===
print("\n=== Requests ===")
response = requests.put(url, headers=headers, json=payload)
print("Status:", response.status_code)
print("Response:", response.text)
print("Sent Headers:")
for k, v in response.request.headers.items():
print(f"{k}: {v}")
Again any help will be appreciated
Step is not included in allowed settings. Please create a bug report, I will update it later.
1 Like
Maksym added this change
For anyone needing python code for updateComboBot here it is below
import base64
import json
import time
import requests
from hashlib import sha256
from hmac import HMAC
# === Credentials ===
api_token = '64ecaxxx' # generate from gainium API
api_secret = 'e12cxxx' # generate from gainium API
# === Clone parameters ===
bot_id = '68ef06xxx' botID to update
# === Timestamp ===
timestamp = str(int(time.time() * 1000))
# === Payload ===
payload = { "step": "3.0"} # your changes payload
body_str = json.dumps(payload, separators=(',', ':'), sort_keys=True)
# === Endpoint ===
endpoint = f"/api/updateComboBot?botId={bot_id}&paperContext=false"
url = f"https://api.gainium.io{endpoint}"
# === Signature ===
prehash_string = f"{body_str}POST{endpoint}{timestamp}"
signature = HMAC(api_secret.encode('utf-8'), prehash_string.encode('utf-8'), sha256).digest()
signature_encoded = base64.b64encode(signature).decode('utf-8')
# === Shared headers ===
headers = {
"accept": "application/json",
"Content-Type": "application/json",
"token": api_token,
"time": timestamp,
"signature": signature_encoded
}
# === Send with requests ===
print("\n=== Requests ===")
response = requests.post(url, headers=headers, json=payload)
print("Status:", response.status_code)
print("Response:", response.text)
print("Sent Headers:")
for k, v in response.request.headers.items():
print(f"{k}: {v}")
1 Like