Skip to content

Instantly share code, notes, and snippets.

Created September 15, 2016 08:25
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 anonymous/e646d71bf52c3eba513160f42e8298a2 to your computer and use it in GitHub Desktop.
Save anonymous/e646d71bf52c3eba513160f42e8298a2 to your computer and use it in GitHub Desktop.
import requests
import urllib
import hashlib
import hmac
import time
key = '先ほど取得したkey'
secret = '先ほど取得したsecret'
trade_url = 'https://api.zaif.jp/tapi'
nonce = time.time()
method = 'get_info'
payload = {'nonce': str(nonce), 'method': method}
headers = {'key': key, 'sign': hmac.new(secret, urllib.urlencode(payload), hashlib.sha512).hexdigest()}
print requests.post(trade_url, data=urllib.urlencode(payload), headers=headers, timeout=3).json()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment