· 8 years ago · Jan 08, 2018, 01:22 AM
1userID = 'up103735192'
2
3def get_prices(a_timestamp, a_signature):
4 while True:
5 #print(making the rest call for BTC/USD")
6 body = json.loads('{"key": "Ztpj8JjqftGQHvEsovxeVg8Ko" , "signature" : "' + str(a_signature).upper() + '","nonce" : "' + str(a_timestamp) +'" }')
7
8 p1 = requests.post('https://cex.io/api/balance/',body )
9
10def create_signature(auserID, secret_key): # (string key, string secret)
11 timestamp = int(datetime.datetime.now().timestamp()) # UNIX timestamp in seconds
12 string = "{}{}".format(timestamp, auserID)
13 return timestamp, hmac.new(string.encode(),secret_key.encode(), hashlib.sha256).hexdigest()
14
15my_timestamp, my_signature = create_signature(userID, secret_API_KEY)
16get_prices(my_timestamp,my_signature)