question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to get Account info with User Data Stream?

See original GitHub issue

Sorry if this is a bit off topic (using raw Node with ws), but maybe someone who answers could explain how to do this with node-binance-api? Although just vanilla node answer would be GREATLY appreciated too =)))

I’m using Node and the ws npm package to work with WebSockets. Got the listenKey as stated in the docs, but I’m unable to get my account info used User Data Stream. I’d prefer to use a stream to read my most current account info (balances, etc) since using the Rest API to do it incurs a penalty (WEIGHT: 5) each time.

The User Data Stream docs say “Account state is updated with the outboundAccountInfo event.” Does that mean that you can only update your account via the stream, but not read your current account info?

I’ve tried doing ws.send('outboundAccountInfo') and then have a ws.on('message', msg => { console.log(msg)}) but no joy.

DOCS: https://github.com/binance-exchange/binance-official-api-docs/blob/master/user-data-stream.md

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
bengrunfeldcommented, Mar 5, 2018

@jaggedsoft Thank you very much for answering my above question. Can you help create a simple ws implementation? What am I missing in the code below? I really want to beat this one 😉

async function main() {
  const uds = await createUserDataStream()

  uds.on('message', msg => {
    console.log(msg)
  })
}

async function createUserDataStream() {
  // returns valid listenKey
  const listenKey = await getListenKey()

  const p = new Promise((resolve, reject) => {
    const endpoint = `${BINANCE_DATA_STREAM_ENDPOINT}/${listenKey}`
    const ws = new WebSocket(endpoint)

    ws.on('open', () => {
      resolve(ws)
    }, error => { 
      reject(error) 
    })
  })

  p.catch(error => console.log(error))

  return p
}
1reaction
bengrunfeldcommented, Mar 5, 2018

@jaggedsoft That’s about the nicest compliment I’ve received in a while!!! It’s all yours. Unfortunately my implementation above does not return any data, but also does not error out =( Thanks for the help all the same!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

BINANCE API - How to get Account info with User Data Stream
I'm using Node and the ws npm package to work with WebSockets. Got the listenKey as stated in the docs (below), but I'm...
Read more >
binance-official-api-docs/user-data-stream.md at master
Go to file T · Go to line L · Copy path · Copy permalink.
Read more >
Javascript – BINANCE API – How to get Account info with User Data ...
Javascript – BINANCE API – How to get Account info with User Data Stream. apijavascriptnode.jswebsocket. I'm using Node and the ws npm package...
Read more >
Updates to the User Data Stream Websocket Payloads
Users that wish to query their full account information can continue to do so via GET /api/v3/account. For further information, please refer to...
Read more >
Connecting a User Data Stream Web Socket with the Binance ...
In this video we work on using asynchronous programming to simultaneously receive live user data through a web socket stream while ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found