Thanks bigtime @gregster
Class act. Will be donating to the AHK Foundation.
Binance API- Passing Security (Header or body)
-
- Posts: 44
- Joined: 08 Nov 2021, 23:40
Re: Binance API- Passing Security (Header or body)
Hello everyone!
Unfortunately, I don't know English well enough to understand the messages in this thread.
I already have working Autohotkey code for "WinHttp.WinHttpRequest.5.1" request on one crypto exchange and now I need to create the same one for Binance.
I would be grateful if someone would post a working code on Autohotkey with a request for Binance, for example, to create an order or another.
Unfortunately, I don't know English well enough to understand the messages in this thread.
I already have working Autohotkey code for "WinHttp.WinHttpRequest.5.1" request on one crypto exchange and now I need to create the same one for Binance.
I would be grateful if someone would post a working code on Autohotkey with a request for Binance, for example, to create an order or another.
Re: Binance API- Passing Security (Header or body)
I try this code but the answer is:
"{"code":-1104,"msg":"Not all sent parameters were read; read '2' parameter(s) but was sent '3'."}"
if you do it like this:
url := "https://api.binance.com/api/v3/account?" postdata "&signature=" sign
then the answer comes:
{"code":-1104,"msg":"Not all sent parameters were read; read '1' parameter(s) but was sent '2'."}
Why can't binance read the parameter?
"{"code":-1104,"msg":"Not all sent parameters were read; read '2' parameter(s) but was sent '3'."}"
if you do it like this:
url := "https://api.binance.com/api/v3/account?" postdata "&signature=" sign
then the answer comes:
{"code":-1104,"msg":"Not all sent parameters were read; read '1' parameter(s) but was sent '2'."}
Why can't binance read the parameter?
Code: Select all
oHTTP:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
apikey :=
secret :=
timestamp := A_NowUTC
timestamp -= 19700101000000, s
timestamp := timestamp * 1000 + A_MSec
postdata := "TimeStamp=" timestamp
sign := LC_HMAC(secret, postdata, "sha256")
url := "https://api.binance.com/api/v3/account?" postdata "&recvWindow=60000&signature=" sign
oHTTP.Open("GET", URL , False) //Post request
oHTTP.SetRequestHeader("X-MBX-APIKEY", apikey)
oHTTP.SetRequestHeader("Sign", sign)
oHTTP.Send() //Send POST request
msgbox, %response%
Last edited by gregster on 08 Jul 2022, 08:09, edited 1 time in total.
Re: Binance API- Passing Security (Header or body)
I managed to solve the problem, the script worked when I replaced
to
Here is the working code for the GET request:
But the POST request does not work yet, I will be grateful for a working example.
Code: Select all
postdata := "TimeStamp=" timestamp
Code: Select all
postdata := "timestamp=" timestamp
Code: Select all
apikey :=
secret :=
oHTTP:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
timestamp := A_NowUTC
timestamp -= 19700101000000, s
timestamp := timestamp * 1000 + A_MSec
postdata := "timestamp=" timestamp
sign := LC_HMAC(secret, timestamp, "sha256")
url := "https://api.binance.com/api/v3/account?" timestamp "&signature=" sign
oHTTP.Open("GET", URL , 0) //Post request
oHTTP.SetRequestHeader("X-MBX-APIKEY", apikey)
oHTTP.SetRequestHeader("Sign", sign)
oHTTP.Send() //Send POST request
response := oHTTP.ResponseText
msgbox, %response%