bitvavo / go-bitvavo-api

Go wrapper for Bitvavo API
ISC License
3 stars 4 forks source link

bitvavo.Markets(map[string]string{"market": "BTC-EUR"}) fails to decode json response #4

Open pavelsmolensky opened 3 years ago

pavelsmolensky commented 3 years ago

Version: github.com/bitvavo/go-bitvavo-api v1.2.0

b = bitvavo.Bitvavo{
        ApiKey:       "***",
        ApiSecret:    "***",
        RestUrl:      "https://api.bitvavo.com/v2",
        WsUrl:        "wss://ws.bitvavo.com/v2/",
        AccessWindow: 10000,
        Debugging:    false,
    }

_, err := b.Markets(map[string]string{"market": "BTC-EUR"})
if err != nil {
    log.Fatal(err)
}

Results in

Error returned by API: errorCode:0, Message:

The root cause is that response for /markets?market=BTC-EUR contains json object, instead of json array expected by the lib: https://github.com/bitvavo/go-bitvavo-api/blob/master/bitvavo.go#L716

Underlying error is json: cannot unmarshal object into Go value of type []bitvavo.Markets

PsySolix commented 3 years ago

Have the same issue..