Last active
November 2, 2018 06:47
-
-
Save googya/148a8d38b208a28c9e2f6a1463a5044e to your computer and use it in GitHub Desktop.
coinfit.io api request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
import hashlib | |
import time | |
import hmac | |
import requests | |
access_key = "access_key" | |
secret_key = "secret_key" | |
url = "/api/orders" | |
payload = { | |
"access_key": access_key, | |
"market": "LTC_BTC", | |
"tonce": int(time.time()) * 1000 | |
} | |
sorted_values = sorted(payload.items(), key=lambda val: val[0]) | |
data=urllib.urlencode(sorted_values) | |
sss = "GET|%s|%s" % (url, data) | |
t = hmac.new(secret_key, sss, hashlib.sha256) | |
payload["signature"] = t.hexdigest() | |
req_url = "https://api.coinfit.io%s" % url | |
result = requests.get(url = req_url, params = payload) | |
print result.json() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment