Skip to content

Instantly share code, notes, and snippets.

@buddies2705
Created June 10, 2020 02:06
Show Gist options
  • Select an option

  • Save buddies2705/753d5b88f0b7ba411f49713e82cc0e10 to your computer and use it in GitHub Desktop.

Select an option

Save buddies2705/753d5b88f0b7ba411f49713e82cc0e10 to your computer and use it in GitHub Desktop.
Get bitFlyer Balance
import requests
import json
import time
import hmac
import hashlib
import base64
API_ENDPOINT = 'https://api.bitflyer.com'
key = 'YOUR_API_KEY'
secret = "YOUR_API_SECRET"
def prepareHeaders(method, path, requestBody):
timestamp = str(time.time())
if requestBody == '':
text = timestamp + method + path
else:
text = timestamp + method + path + json.dumps(requestBody)
signature = hmac.new(secret.encode('utf-8'), text.encode('utf-8'), hashlib.sha256).hexdigest()
headers = {'Content-Type': 'application/json',
'ACCESS-KEY': key,
'ACCESS-TIMESTAMP': timestamp,
'ACCESS-SIGN': signature}
return headers
def convetStrToJson(str):
return json.loads(str)
def getMyBalance():
url = API_ENDPOINT
path = '/v1/me/getbalance'
headers = prepareHeaders('GET', path , '')
response = requests.get( url + path, headers=headers)
response = convetStrToJson(response.text)
print(response)
return response
getMyBalance()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment