私はpythonで新しいです。ほんの数時間それを学ぶ。Pythonでエラーが発生したBlinktrade Rest APIを使用しています
私はここに...いくつかのアカウントに関する情報を取得するために、REST APIを消費する
をしようとしているが、私のリクエストです:
def getAccountData():
nonce = int(datetime.datetime.now().timestamp())
signature = hmac.new(b'TDDh8djV3NwXt53gSrScDul6o6w3HnnZsHuh6HTF9SA', msg=nonce, digestmod=hashlib.sha256).digest()
print(signature)
headers = {
'content-type': 'application/json',
'APIKey':conf['API_KEY'],
'Nonce':str(nonce),
}
data = {
"MsgType": "U2",
"BalanceReqID": 1
}
r = requests.post('https://api.blinktrade.com/tapi/v1/message', data=data, headers=headers)
print(r.json())
そして、ここではエラーです:
Traceback (most recent call last): File "foxbit.py", line 51, in getAccountData() File "foxbit.py", line 30, in getAccountData signature = hmac.new(b'TDDh8djV3NwXt53gSrScDul6o6w3HnnZsHuh6HTF9SA', msg=nonce, digestmod=hashlib.sha256).digest() File "C:\Python\Python35\lib\hmac.py", line 144, in new return HMAC(key, msg, digestmod) File "C:\Python\Python35\lib\hmac.py", line 84, in init self.update(msg) File "C:\Python\Python35\lib\hmac.py", line 93, in update self.inner.update(msg) TypeError: object supporting the buffer API required
私はこのAPIを消費しようとしています: https://blinktrade.com/docs/?shell#balance
on balance
メソッド
成功しません。
私はBitcoinの開かれた注文を見るために、Pythonアプリケーションを作成したいと思います。 このエラーは何が起こっていましたか?ドキュメントでは、私は仕事にこれを行う必要があると言います:
{
"MsgType": "U2",
"BalanceReqID": 1
}
message='{ "MsgType": "U2", "BalanceReqID": 1 }'
api_url='API_URL_REST_ENDPOINT'
api_key='YOUR_API_KEY_GENERATED_IN_API_MODULE'
api_secret='YOUR_SECRET_KEY_GENERATED_IN_API_MODULE'
nonce=`date +%s`
signature=`echo -n "$nonce" | openssl dgst -sha256 -hex -hmac "$api_secret" | cut -d ' ' -f 2`
curl -X POST "$api_url" \
-H "APIKey:$api_key" \
-H "Nonce:$nonce" \
-H "Signature:$signature" \
-H "Content-Type:application/json" \
-d "$message"
3時間試してみてください! hehe 私はここでいくつかの助けが必要です。