Binance Portfolio Margin REST portfoliomargin private JavaScript example. Review the source code and SDK calls, then browse related integration examples.
This example uses binance, the JavaScript and TypeScript SDK for Binance. Install it with npm install binance.
We use environment variables in our examples for API keys. It is your responsibility to manage and secure your keys appropriately.
binance instead of hand-written HTTP request plumbing.Binance/REST/Portfolio Margin/rest-portfoliomargin-private.ts.PortfolioClient.getBalance(), getPMUserDataListenKey(), submitNewUMOrder().import { PortfolioClient } from 'binance'; const key = process.env.API_KEY_COM || 'APIKEY';const secret = process.env.API_SECRET_COM || 'APISECRET'; const client = new PortfolioClient({ api_key: key, api_secret: secret, beautifyResponses: true,}); (async () => { try { const res = await client.getBalance(); console.log('res', res); const listenKey = await client.getPMUserDataListenKey(); console.log('listen key res: ', listenKey); // const newOrderRes = await client.submitNewUMOrder({ // symbol: 'BTCUSDT', // side: 'BUY', // type: 'MARKET', // quantity: '10', // }); // console.log('new order res: ', newOrderRes); } catch (e) { console.error('request failed: ', e); }})(); We use essential cookies and optional analytics. Read the Privacy Policy.
Essential cookies stay on. Toggle analytics if you want to share anonymous usage insights. You can revisit this anytime via Cookie Settings in the footer.