Rest API with AHK

Get help with using AutoHotkey and its commands and hotkeys
Bensley
Posts: 6
Joined: 18 Nov 2017, 06:18

Rest API with AHK

18 Nov 2017, 07:10

I need a huge favor.
I would like to try REST api (demo account) to my broker but having problems .
Does anybody know how to implement HTTP request with AHK?
On a broker page there is a tutorial for a very simple account info that goes like this:

***************************************************************************************************************************************
Examples
curl: Get Account list for current auth token

Request

Code: Select all

curl \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <AUTHENTICATION TOKEN>" \
  "https://api-fxpractice.oanda.com/v3/accounts"
Response Headers:

Code: Select all

HTTP/1.1 200 OK
Access-Control-Allow-Headers: Authorization, Content-Type, Accept-Datetime-Format
Content-Encoding: gzip
Transfer-Encoding: chunked
Server: openresty/1.7.0.1
Connection: keep-alive
Date: Wed, 22 Jun 2016 18:32:01 GMT
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: PUT, PATCH, POST, GET, OPTIONS, DELETE
Content-Type: application/json; charset=UTF-8

Response Body

Code: Select all

{
  "accounts": [
    {
      "id": "101-004-7193916-001", 
      "tags": []
    }
  ]
}
***************************************************************************************************************************************
Notice that there are already 3 inputs inserted there :
URL:https://api-fxpractice.oanda.com
Account id: 101-004-7193916-001
Security token:80b44ea9c302237f9178a137d9e86deb-20083fb12d9579469f24afa80816066b

Can anybody make working ahk script out of this, i just need that initial first step
to have any clue how to proceed with more complicated stuff than this.
teadrinker
Posts: 2076
Joined: 29 Mar 2015, 09:41
Contact:

Re: Rest API with AHK

18 Nov 2017, 10:22

Hi, Bensley,

Code: Select all

oWhr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
oWhr.Open("GET", "https://api-fxpractice.oanda.com/v3/accounts", false)
oWhr.SetRequestHeader("Content-Type", "application/json")
oWhr.SetRequestHeader("Authorization", "Bearer 80b44ea9c302237f9178a137d9e86deb-20083fb12d9579469f24afa80816066b")
oWhr.Send()
MsgBox, % oWhr.ResponseText
Bensley
Posts: 6
Joined: 18 Nov 2017, 06:18

Re: Rest API with AHK

18 Nov 2017, 14:37

Wow thank you teadrinker, you are a lifesaver. :bravo:
It works and also with the little adjusting a lot of other Api calls are possible to me now.
I even manage to send (POST) orders :dance:
loumizhu
Posts: 4
Joined: 18 Aug 2016, 22:07

Re: Rest API with AHK

02 Nov 2019, 06:36

teadrinker: thank youuu

Return to “Ask For Help”

Who is online

Users browsing this forum: alancantor, djuga, Freshman, JackbobEvolved, martin536, pythonker and 35 guests