0

I wanted to retrieve the different prices given by then kraken API but i'm not very familiar with the construction of POST requests.

I retrieve a code which could make the request but without any parameters:

Sub retrieve_price()
Const sUrl As String = "https://api.kraken.com/0/public/Ticker"

Dim oRequest As WinHttp.WinHttpRequest
Dim sResult As String

Set oRequest = New WinHttp.WinHttpRequest
With oRequest
    .Open "POST", sUrl, True
    .Send 
    .WaitForResponse
    sResult = .ResponseText
End With

Range("A1") = sResult


End Sub

kraken API information

From the kraken API information they write:

Get ticker information
URL: https://api.kraken.com/0/public/Ticker

Input:

pair = comma delimited list of asset pairs to get info on

(same as enclosed picture or on https://www.kraken.com/help/api#public-market-data)

However to add this parameter i tried both:

In my with add:

.SetRequestHeader "pair", "ETHEUR"

and also:

.SetRequestHeader "Content-Type", "pair=ETHEUR"

or instead write for my send:

.Send ("pair=ETHEUR")

but both ways didn't work and i don't know how i should proceed then. I read How are parameters sent in an HTTP POST request? But i didn't understand how to apply what was written on the post Could someone give me a piece of advice about it? Many thanks!

ploom
  • 5
  • 2

1 Answers1

0

I think you want a GET request.

If you type the following into a Web Browser:

https://api.kraken.com/0/public/Ticker?pair=ETHEUR

You should get a response something like this:

{"error":[],"result":{"XETHZEUR":{"a":["167.71714","1","1.000"],"b":
["167.65000","200","200.000"],"c":["167.71822","0.25164886"],"v":
["351548.13416062","386545.69665419"],"p":["169.62204","170.24439"],"t": 
[50582,55183],"l":["151.00995","151.00995"],"h":
["190.98999","190.98999"],"o":"181.57867"}}}

You should be able this parse this JSON response to get at what you need.

Ryan Wildry
  • 5,339
  • 1
  • 13
  • 31