const WebSocket = require('ws');
const ws = new WebSocket('wss://analytics-ws.amberdata.com/prices', {
headers: { 'x-api-key': '<api_key>' }
});
ws.on('open', () => {
ws.send(JSON.stringify({
jsonrpc: '2.0',
method: 'subscribe',
params: ['prices:spot:asset', { asset: 'all' }],
id: 1
}));
});
ws.on('message', data => {
console.log(JSON.stringify(JSON.parse(data), null, 2));
});