2017-09-23 92 views
0

我期待在上Coinbase的Github上的文檔的GDAX API,並試圖訂閱心跳通道,但保持與下面的錯誤時返回,當我使用這個代碼:GDAX心跳通道

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); 
    }); 

錯誤:

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

回答

0

一定要包括"product_ids" : ["BTC-GBP"]作爲JSON請求的字段。

所以這樣的事情應該工作(從他們的API文檔)

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

看到這裏https://docs.gdax.com/#subscribe