Skip to content

Instantly share code, notes, and snippets.

@googya
Last active November 2, 2018 06:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save googya/148a8d38b208a28c9e2f6a1463a5044e to your computer and use it in GitHub Desktop.
Save googya/148a8d38b208a28c9e2f6a1463a5044e to your computer and use it in GitHub Desktop.
coinfit.io api request
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