Python-binance: binance.exceptions.BinanceAPIException: APIError(code=-1022): Signature for this request is not valid.

Created on 8 Sep 2017  路  3Comments  路  Source: sammchardy/python-binance

Hi!

First of all, thank you for the implementation!

However I run into a problem and hoping for your help.
I am using this code.

from binance import client

APIKEY_BINANCE ='XXXXXX'
SECRETKEY_BINANCE = 'XXXXXX'

client = client.Client(APIKEY_BINANCE, SECRETKEY_BINANCE)

print(client.get_account()`

For some reason, a lot of my requests do not go through due to the signature, resulting in this error:

{"code":-1022,"msg":"Signature for this request is not valid."}
Traceback (most recent call last):
  File "/home/huynh/PycharmProjects/gdax_rl/binance_test.py", line 13, in <module>
    print(client.get_account())
  File "/home/huynh/PycharmProjects/gdax_rl/binance/client.py", line 311, in get_account
    return self._get('account', True, data=params)
  File "/home/huynh/PycharmProjects/gdax_rl/binance/client.py", line 101, in _get
    return self._request('get', path, signed, **kwargs)
  File "/home/huynh/PycharmProjects/gdax_rl/binance/client.py", line 73, in _request
    return self._handle_response(response)
  File "/home/huynh/PycharmProjects/gdax_rl/binance/client.py", line 97, in _handle_response
    raise BinanceAPIException(response)
binance.exceptions.BinanceAPIException: APIError(code=-1022): Signature for this request is not valid.

Process finished with exit code 1

However, some requests work without a problem.

Do you know how I can fix that?

Best regards,

Most helpful comment

A SIGNED endpoint also requires a parameter, timestamp, to be sent which should be the millisecond timestamp of when the request was created and sent.
An additional parameter, recvWindow, may be sent to specific the number of milliseconds after timestamp the request is valid for. If recvWindow is not sent, it defaults to 5000 millisecond.
The logic is as follows:

if (timestamp < serverTime && (serverTime - timestamp) <= recvWindow) {
  // process request
} else {
  // reject request
}

can set request parameter 'recvWindow=6000000'

All 3 comments

i have same problem
binance.exceptions.BinanceAPIException: APIError(code=-1121): Invalid symbol.
why?

@ohsnapitsjojo are you fix youself?

A SIGNED endpoint also requires a parameter, timestamp, to be sent which should be the millisecond timestamp of when the request was created and sent.
An additional parameter, recvWindow, may be sent to specific the number of milliseconds after timestamp the request is valid for. If recvWindow is not sent, it defaults to 5000 millisecond.
The logic is as follows:

if (timestamp < serverTime && (serverTime - timestamp) <= recvWindow) {
  // process request
} else {
  // reject request
}

can set request parameter 'recvWindow=6000000'

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Astrantia picture Astrantia  路  9Comments

alexandre-a picture alexandre-a  路  4Comments

iamveritas picture iamveritas  路  3Comments

echel0n picture echel0n  路  4Comments

.
Rob-bb picture Rob-bb  路  6Comments