0

I'm looking at the documentation on Coinbase's Github for the GDAX API and trying to subscribe to the heartbeat channel, but keep being returned with the below error when I utilize this code:

var websocket = new Gdax.WebsocketClient(
    ['BTC-USD'],
    'wss://ws-feed.gdax.com',
    {
        key: API_KEY,
        secret: API_SECRET,
        passphrase: API_PASSPHRASE,
    },
    { heartbeat: true }
)
  webSocket.on('message', data => {
    console.log(data);
  });

Error:

{ 
    type: 'error',
    message: 'Failed to subscribe',
    reason: 'You need to specify at least one product ID for channel heartbeat'
}

1 Answers1

0

Be sure to include "product_ids" : ["BTC-GBP"] as a field in the Json request.

So something like this should work (from their API docs)

{
    "type": "subscriptions",
    "channels": [        
        {
            "name": "heartbeat",
            "product_ids": [
                "ETH-USD",
                "ETH-EUR"
            ],
        }
    ]
}

See here https://docs.gdax.com/#subscribe

Rob Evans
  • 2,822
  • 1
  • 9
  • 15