binance-exchange/node-binance-api

Balance function

HueyFiasco opened this issue · 11 comments

There is an error using the basic balance function. Thanks.

What is the error?
Can verify it's working as intended
This function will be improved soon to include the btcValue, ethValue and bnbValue of all coins you own

binance.balance(function(error, balances) {
	if ( error ) return console.error(error);
	let balance = {};
	for ( let asset in balances ) {
		let obj = balances[asset];
		balance[asset] = obj;
	}
	console.log(balance);
});

This is the error I'm currently getting:

console.log("ETH balance: ", balances.ETH.available);
^

TypeError: Cannot read property 'available' of undefined
at binance.balance (C:\Users\Afro\Desktop\binance_update\myfirst2.js:120:45)
at C:\Users\Afro\Desktop\binance_update\node_modules\node-binance-api\node-binance-api.js:727:33
at Request._callback (C:\Users\Afro\Desktop\binance_update\node_modules\node-binance-api\node-binance-api.js:147:24)
at Request.self.callback (C:\Users\Afro\Desktop\binance_update\node_modules\request\request.js:186:22)
at emitTwo (events.js:125:13)
at Request.emit (events.js:213:7)
at Request. (C:\Users\Afro\Desktop\binance_update\node_modules\request\request.js:1163:10)
at emitOne (events.js:115:13)
at Request.emit (events.js:210:7)
at IncomingMessage. (C:\Users\Afro\Desktop\binance_update\node_modules\request\request.js:1085:12)

Have you tried the function I provided? It will tell you errors, such as missing API key, etc

[ 'balanceData error', {} ]
IncomingMessage {
_readableState:
ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: BufferList { head: null, tail: null, length: 0 },
length: 0,
pipes: null,
pipesCount: 0,
flowing: true,
ended: true,
endEmitted: true,
reading: false,
sync: false,
needReadable: false,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
destroyed: false,
defaultEncoding: 'utf8',
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: false,
domain: null,
_events:
{ end: [ [Function: responseOnEnd], [Function] ],
close: [ [Function], [Function] ],
data: [Function],
error: [Function] },
_eventsCount: 4,
_maxListeners: undefined,
socket:
TLSSocket {
_tlsOptions:
{ pipe: false,
secureContext: [Object],
isServer: false,
requestCert: true,
rejectUnauthorized: true,
session: undefined,
NPNProtocols: undefined,
ALPNProtocols: undefined,
requestOCSP: undefined },
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: null,
npnProtocol: false,
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events:
{ close: [Array],
end: [Object],
finish: [Function: onSocketFinish],
_socketEnd: [Function: onSocketEnd],
secure: [Function],
free: [Function: onFree],
agentRemove: [Function: onRemove],
drain: [Function: ondrain],
error: [Function: socketErrorListener],
timeout: [Object] },
_eventsCount: 10,
connecting: false,
_hadError: false,
_handle: null,
_parent: null,
_host: 'api.binance.com',
_readableState:
ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: [Object],
length: 0,
pipes: null,
pipesCount: 0,
flowing: true,
ended: false,
endEmitted: false,
reading: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
destroyed: true,
defaultEncoding: 'utf8',
awaitDrain: 0,
readingMore: true,
decoder: null,
encoding: null },
readable: false,
domain: null,
_maxListeners: undefined,
_writableState:
WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: false,
needDrain: false,
ending: true,
ended: true,
finished: true,
destroyed: true,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: false,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
bufferedRequest: null,
lastBufferedRequest: null,
pendingcb: 0,
prefinished: true,
errorEmitted: false,
bufferedRequestCount: 0,
corkedRequestsFree: [Object] },
writable: false,
allowHalfOpen: false,
_bytesDispatched: 375,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage:
ClientRequest {
domain: null,
_events: [Object],
_eventsCount: 6,
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
outputSize: 0,
writable: true,
_last: true,
upgrading: false,
chunkedEncoding: false,
shouldKeepAlive: false,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: [Circular],
connection: [Circular],
_header: 'GET /api/v3/account?timestamp=1518291995575&recvWindow=60000&signature=d7be7e854bc3093820b6a685f772f1df60fa7afbc946077ee3085c115fa046c9 HTTP/1.1\r\nUser-Agent: Mozilla/4.0 (compatible; Node Binance API)\r\nContent-type: application/x-www-form-urlencoded\r\nX-MBX-APIKEY: iOBA7Ae43YOpIxNds3MXTIkyAm0ULxkO0oYAnvHZw3EiSg7zIrpbSdjp3XcrG0nh\r\nhost: api.binance.com\r\nConnection: close\r\n\r\n',
_onPendingData: [Function: noopPendingOutput],
agent: [Object],
socketPath: undefined,
timeout: undefined,
method: 'GET',
path: '/api/v3/account?timestamp=1518291995575&recvWindow=60000&signature=d7be7e854bc3093820b6a685f772f1df60fa7afbc946077ee3085c115fa046c9',
_ended: true,
res: [Circular],
aborted: undefined,
timeoutCb: [Function: emitTimeout],
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
[Symbol(outHeadersKey)]: [Object] },
read: [Function],
_consuming: true,
_idleTimeout: -1,
_idleNext: null,
_idlePrev: null,
_idleStart: 1045,
_destroyed: false,
[Symbol(asyncId)]: 10,
[Symbol(bytesRead)]: 351,
[Symbol(asyncId)]: 23,
[Symbol(triggerAsyncId)]: 19 },
connection:
TLSSocket {
_tlsOptions:
{ pipe: false,
secureContext: [Object],
isServer: false,
requestCert: true,
rejectUnauthorized: true,
session: undefined,
NPNProtocols: undefined,
ALPNProtocols: undefined,
requestOCSP: undefined },
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: null,
npnProtocol: false,
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events:
{ close: [Array],
end: [Object],
finish: [Function: onSocketFinish],
_socketEnd: [Function: onSocketEnd],
secure: [Function],
free: [Function: onFree],
agentRemove: [Function: onRemove],
drain: [Function: ondrain],
error: [Function: socketErrorListener],
timeout: [Object] },
_eventsCount: 10,
connecting: false,
_hadError: false,
_handle: null,
_parent: null,
_host: 'api.binance.com',
_readableState:
ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: [Object],
length: 0,
pipes: null,
pipesCount: 0,
flowing: true,
ended: false,
endEmitted: false,
reading: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
destroyed: true,
defaultEncoding: 'utf8',
awaitDrain: 0,
readingMore: true,
decoder: null,
encoding: null },
readable: false,
domain: null,
_maxListeners: undefined,
_writableState:
WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: false,
needDrain: false,
ending: true,
ended: true,
finished: true,
destroyed: true,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: false,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
bufferedRequest: null,
lastBufferedRequest: null,
pendingcb: 0,
prefinished: true,
errorEmitted: false,
bufferedRequestCount: 0,
corkedRequestsFree: [Object] },
writable: false,
allowHalfOpen: false,
_bytesDispatched: 375,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage:
ClientRequest {
domain: null,
_events: [Object],
_eventsCount: 6,
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
outputSize: 0,
writable: true,
_last: true,
upgrading: false,
chunkedEncoding: false,
shouldKeepAlive: false,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: [Circular],
connection: [Circular],
_header: 'GET /api/v3/account?timestamp=1518291995575&recvWindow=60000&signature=d7be7e854bc3093820b6a685f772f1df60fa7afbc946077ee3085c115fa046c9 HTTP/1.1\r\nUser-Agent: Mozilla/4.0 (compatible; Node Binance API)\r\nContent-type: application/x-www-form-urlencoded\r\nX-MBX-APIKEY: iOBA7Ae43YOpIxNds3MXTIkyAm0ULxkO0oYAnvHZw3EiSg7zIrpbSdjp3XcrG0nh\r\nhost: api.binance.com\r\nConnection: close\r\n\r\n',
_onPendingData: [Function: noopPendingOutput],
agent: [Object],
socketPath: undefined,
timeout: undefined,
method: 'GET',
path: '/api/v3/account?timestamp=1518291995575&recvWindow=60000&signature=d7be7e854bc3093820b6a685f772f1df60fa7afbc946077ee3085c115fa046c9',
_ended: true,
res: [Circular],
aborted: undefined,
timeoutCb: [Function: emitTimeout],
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
[Symbol(outHeadersKey)]: [Object] },
read: [Function],
_consuming: true,
_idleTimeout: -1,
_idleNext: null,
_idlePrev: null,
_idleStart: 1045,
_destroyed: false,
[Symbol(asyncId)]: 10,
[Symbol(bytesRead)]: 351,
[Symbol(asyncId)]: 23,
[Symbol(triggerAsyncId)]: 19 },
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: true,
headers:
{ date: 'Sat, 10 Feb 2018 19:46:34 GMT',
'content-type': 'application/json',
'transfer-encoding': 'chunked',
connection: 'close',
server: 'nginx',
'strict-transport-security': 'max-age=31536000; includeSubdomains',
'x-frame-options': 'SAMEORIGIN' },
rawHeaders:
[ 'Date',
'Sat, 10 Feb 2018 19:46:34 GMT',
'Content-Type',
'application/json',
'Transfer-Encoding',
'chunked',
'Connection',
'close',
'Server',
'nginx',
'Strict-Transport-Security',
'max-age=31536000; includeSubdomains',
'X-Frame-Options',
'SAMEORIGIN' ],
trailers: {},
rawTrailers: [],
upgrade: false,
url: '',
method: null,
statusCode: 400,
statusMessage: 'Bad Request',
client:
TLSSocket {
_tlsOptions:
{ pipe: false,
secureContext: [Object],
isServer: false,
requestCert: true,
rejectUnauthorized: true,
session: undefined,
NPNProtocols: undefined,
ALPNProtocols: undefined,
requestOCSP: undefined },
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: null,
npnProtocol: false,
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events:
{ close: [Array],
end: [Object],
finish: [Function: onSocketFinish],
_socketEnd: [Function: onSocketEnd],
secure: [Function],
free: [Function: onFree],
agentRemove: [Function: onRemove],
drain: [Function: ondrain],
error: [Function: socketErrorListener],
timeout: [Object] },
_eventsCount: 10,
connecting: false,
_hadError: false,
_handle: null,
_parent: null,
_host: 'api.binance.com',
_readableState:
ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: [Object],
length: 0,
pipes: null,
pipesCount: 0,
flowing: true,
ended: false,
endEmitted: false,
reading: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
destroyed: true,
defaultEncoding: 'utf8',
awaitDrain: 0,
readingMore: true,
decoder: null,
encoding: null },
readable: false,
domain: null,
_maxListeners: undefined,
_writableState:
WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: false,
needDrain: false,
ending: true,
ended: true,
finished: true,
destroyed: true,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: false,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
bufferedRequest: null,
lastBufferedRequest: null,
pendingcb: 0,
prefinished: true,
errorEmitted: false,
bufferedRequestCount: 0,
corkedRequestsFree: [Object] },
writable: false,
allowHalfOpen: false,
_bytesDispatched: 375,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage:
ClientRequest {
domain: null,
_events: [Object],
_eventsCount: 6,
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
outputSize: 0,
writable: true,
_last: true,
upgrading: false,
chunkedEncoding: false,
shouldKeepAlive: false,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: [Circular],
connection: [Circular],
_header: 'GET /api/v3/account?timestamp=1518291995575&recvWindow=60000&signature=d7be7e854bc3093820b6a685f772f1df60fa7afbc946077ee3085c115fa046c9 HTTP/1.1\r\nUser-Agent: Mozilla/4.0 (compatible; Node Binance API)\r\nContent-type: application/x-www-form-urlencoded\r\nX-MBX-APIKEY: iOBA7Ae43YOpIxNds3MXTIkyAm0ULxkO0oYAnvHZw3EiSg7zIrpbSdjp3XcrG0nh\r\nhost: api.binance.com\r\nConnection: close\r\n\r\n',
_onPendingData: [Function: noopPendingOutput],
agent: [Object],
socketPath: undefined,
timeout: undefined,
method: 'GET',
path: '/api/v3/account?timestamp=1518291995575&recvWindow=60000&signature=d7be7e854bc3093820b6a685f772f1df60fa7afbc946077ee3085c115fa046c9',
_ended: true,
res: [Circular],
aborted: undefined,
timeoutCb: [Function: emitTimeout],
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
[Symbol(outHeadersKey)]: [Object] },
read: [Function],
_consuming: true,
_idleTimeout: -1,
_idleNext: null,
_idlePrev: null,
_idleStart: 1045,
_destroyed: false,
[Symbol(asyncId)]: 10,
[Symbol(bytesRead)]: 351,
[Symbol(asyncId)]: 23,
[Symbol(triggerAsyncId)]: 19 },
_consuming: true,
_dumped: false,
req:
ClientRequest {
domain: null,
_events:
{ socket: [Function],
response: [Function: bound ],
error: [Array],
drain: [Function],
timeout: [Object],
prefinish: [Function: requestOnPrefinish] },
_eventsCount: 6,
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
outputSize: 0,
writable: true,
_last: true,
upgrading: false,
chunkedEncoding: false,
shouldKeepAlive: false,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket:
TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: null,
npnProtocol: false,
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object],
_eventsCount: 10,
connecting: false,
_hadError: false,
_handle: null,
_parent: null,
_host: 'api.binance.com',
_readableState: [Object],
readable: false,
domain: null,
_maxListeners: undefined,
_writableState: [Object],
writable: false,
allowHalfOpen: false,
_bytesDispatched: 375,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: [Circular],
read: [Function],
_consuming: true,
_idleTimeout: -1,
_idleNext: null,
_idlePrev: null,
_idleStart: 1045,
_destroyed: false,
[Symbol(asyncId)]: 10,
[Symbol(bytesRead)]: 351,
[Symbol(asyncId)]: 23,
[Symbol(triggerAsyncId)]: 19 },
connection:
TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: null,
npnProtocol: false,
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object],
_eventsCount: 10,
connecting: false,
_hadError: false,
_handle: null,
_parent: null,
_host: 'api.binance.com',
_readableState: [Object],
readable: false,
domain: null,
_maxListeners: undefined,
_writableState: [Object],
writable: false,
allowHalfOpen: false,
_bytesDispatched: 375,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: [Circular],
read: [Function],
_consuming: true,
_idleTimeout: -1,
_idleNext: null,
_idlePrev: null,
_idleStart: 1045,
_destroyed: false,
[Symbol(asyncId)]: 10,
[Symbol(bytesRead)]: 351,
[Symbol(asyncId)]: 23,
[Symbol(triggerAsyncId)]: 19 },
_header: 'GET /api/v3/account?timestamp=1518291995575&recvWindow=60000&signature=d7be7e854bc3093820b6a685f772f1df60fa7afbc946077ee3085c115fa046c9 HTTP/1.1\r\nUser-Agent: Mozilla/4.0 (compatible; Node Binance API)\r\nContent-type: application/x-www-form-urlencoded\r\nX-MBX-APIKEY: iOBA7Ae43YOpIxNds3MXTIkyAm0ULxkO0oYAnvHZw3EiSg7zIrpbSdjp3XcrG0nh\r\nhost: api.binance.com\r\nConnection: close\r\n\r\n',
_onPendingData: [Function: noopPendingOutput],
agent:
Agent {
domain: null,
_events: [Object],
_eventsCount: 1,
_maxListeners: undefined,
defaultPort: 443,
protocol: 'https:',
options: [Object],
requests: {},
sockets: [Object],
freeSockets: {},
keepAliveMsecs: 1000,
keepAlive: false,
maxSockets: Infinity,
maxFreeSockets: 256,
maxCachedSessions: 100,
_sessionCache: [Object] },
socketPath: undefined,
timeout: undefined,
method: 'GET',
path: '/api/v3/account?timestamp=1518291995575&recvWindow=60000&signature=d7be7e854bc3093820b6a685f772f1df60fa7afbc946077ee3085c115fa046c9',
_ended: true,
res: [Circular],
aborted: undefined,
timeoutCb: [Function: emitTimeout],
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
[Symbol(outHeadersKey)]:
{ 'user-agent': [Array],
'content-type': [Array],
'x-mbx-apikey': [Array],
host: [Array] } },
request:
Request {
domain: null,
_events:
{ error: [Function: bound ],
complete: [Function: bound ],
pipe: [Function],
data: [Function],
end: [Function] },
_eventsCount: 5,
_maxListeners: undefined,
method: 'GET',
timeout: 60000,
agent:
Agent {
domain: null,
_events: [Object],
_eventsCount: 1,
_maxListeners: undefined,
defaultPort: 443,
protocol: 'https:',
options: [Object],
requests: {},
sockets: [Object],
freeSockets: {},
keepAliveMsecs: 1000,
keepAlive: false,
maxSockets: Infinity,
maxFreeSockets: 256,
maxCachedSessions: 100,
_sessionCache: [Object] },
headers:
{ 'User-Agent': 'Mozilla/4.0 (compatible; Node Binance API)',
'Content-type': 'application/x-www-form-urlencoded',
'X-MBX-APIKEY': 'iOBA7Ae43YOpIxNds3MXTIkyAm0ULxkO0oYAnvHZw3EiSg7zIrpbSdjp3XcrG0nh' },
callback: [Function],
readable: true,
writable: true,
explicitMethod: true,
_qs:
Querystring {
request: [Circular],
lib: [Object],
useQuerystring: undefined,
parseOptions: {},
stringifyOptions: {} },
_auth:
Auth {
request: [Circular],
hasAuth: false,
sentAuth: false,
bearerToken: null,
user: null,
pass: null },
_oauth: OAuth { request: [Circular], params: null },
_multipart:
Multipart {
request: [Circular],
boundary: '530a7fb3-e069-4f4f-86fe-629813efaa62',
chunked: false,
body: null },
_redirect:
Redirect {
request: [Circular],
followRedirect: true,
followRedirects: true,
followAllRedirects: false,
followOriginalHttpMethod: false,
allowRedirect: [Function],
maxRedirects: 10,
redirects: [],
redirectsFollowed: 0,
removeRefererHeader: false },
_tunnel:
Tunnel {
request: [Circular],
proxyHeaderWhiteList: [Array],
proxyHeaderExclusiveList: [] },
setHeader: [Function],
hasHeader: [Function],
getHeader: [Function],
removeHeader: [Function],
localAddress: undefined,
pool: {},
dests: [],
__isRequestRequest: true,
_callback: [Function],
uri:
Url {
protocol: 'https:',
slashes: true,
auth: null,
host: 'api.binance.com',
port: 443,
hostname: 'api.binance.com',
hash: null,
search: '?timestamp=1518291995575&recvWindow=60000&signature=d7be7e854bc3093820b6a685f772f1df60fa7afbc946077ee3085c115fa046c9',
query: 'timestamp=1518291995575&recvWindow=60000&signature=d7be7e854bc3093820b6a685f772f1df60fa7afbc946077ee3085c115fa046c9',
pathname: '/api/v3/account',
path: '/api/v3/account?timestamp=1518291995575&recvWindow=60000&signature=d7be7e854bc3093820b6a685f772f1df60fa7afbc946077ee3085c115fa046c9',
href: 'https://api.binance.com/api/v3/account?timestamp=1518291995575&recvWindow=60000&signature=d7be7e854bc3093820b6a685f772f1df60fa7afbc946077ee3085c115fa046c9' },
proxy: null,
tunnel: true,
setHost: true,
originalCookieHeader: undefined,
_disableCookies: true,
jar: undefined,
port: 443,
host: 'api.binance.com',
path: '/api/v3/account?timestamp=1518291995575&recvWindow=60000&signature=d7be7e854bc3093820b6a685f772f1df60fa7afbc946077ee3085c115fa046c9',
httpModule:
{ Server: [Object],
createServer: [Function: createServer],
globalAgent: [Object],
Agent: [Object],
request: [Function: request],
get: [Function: get] },
agentClass: { [Function: Agent] super
: [Object] },
_started: true,
href: 'https://api.binance.com/api/v3/account?timestamp=1518291995575&recvWindow=60000&signature=d7be7e854bc3093820b6a685f772f1df60fa7afbc946077ee3085c115fa046c9',
req:
ClientRequest {
domain: null,
_events: [Object],
_eventsCount: 6,
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
outputSize: 0,
writable: true,
_last: true,
upgrading: false,
chunkedEncoding: false,
shouldKeepAlive: false,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: [Object],
connection: [Object],
_header: 'GET /api/v3/account?timestamp=1518291995575&recvWindow=60000&signature=d7be7e854bc3093820b6a685f772f1df60fa7afbc946077ee3085c115fa046c9 HTTP/1.1\r\nUser-Agent: Mozilla/4.0 (compatible; Node Binance API)\r\nContent-type: application/x-www-form-urlencoded\r\nX-MBX-APIKEY: iOBA7Ae43YOpIxNds3MXTIkyAm0ULxkO0oYAnvHZw3EiSg7zIrpbSdjp3XcrG0nh\r\nhost: api.binance.com\r\nConnection: close\r\n\r\n',
_onPendingData: [Function: noopPendingOutput],
agent: [Object],
socketPath: undefined,
timeout: undefined,
method: 'GET',
path: '/api/v3/account?timestamp=1518291995575&recvWindow=60000&signature=d7be7e854bc3093820b6a685f772f1df60fa7afbc946077ee3085c115fa046c9',
_ended: true,
res: [Circular],
aborted: undefined,
timeoutCb: [Function: emitTimeout],
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
[Symbol(outHeadersKey)]: [Object] },
ntick: true,
timeoutTimer: null,
response: [Circular],
originalHost: 'api.binance.com',
originalHostHeaderName: 'host',
responseContent: [Circular],
_destdata: true,
_ended: true,
_callbackCalled: true },
toJSON: [Function: responseToJSON],
caseless:
Caseless {
dict:
{ date: 'Sat, 10 Feb 2018 19:46:34 GMT',
'content-type': 'application/json',
'transfer-encoding': 'chunked',
connection: 'close',
server: 'nginx',
'strict-transport-security': 'max-age=31536000; includeSubdomains',
'x-frame-options': 'SAMEORIGIN' } },
read: [Function],
body: '{"code":-1021,"msg":"Timestamp for this request was 1000ms ahead of the server's time."}' }

It looks like I'm ahead of the server's time. Also most likely repeating itself for each kind of stock.

Thankfully there is an easily solution for this
You can synchronize your system time
Or add useServerTime: true to the options

Yea I trying to use that then this happens:

useServerTime: true, // If you get timestamp errors, synchronize to server time at startup
^^^^^^^^^^^^^

SyntaxError: Unexpected identifier
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:576:28)
at Object.Module._extensions..js (module.js:623:10)
at Module.load (module.js:531:32)
at tryModuleLoad (module.js:494:12)
at Function.Module._load (module.js:486:3)
at Function.Module.runMain (module.js:653:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3

With my code being:

const binance = require('node-binance-api');

binance.options({
'APIKEY':'xxxxxxxxxxxxxx
'APISECRET':'xxxxxxxxxxxxxxxxxxxxxxxx
useServerTime: true, // If you get timestamp errors, synchronize to server time at startup
});

binance.balance(function(error, balances) {
if ( error ) return console.error(error);
let balance = {};
for ( let asset in balances ) {
let obj = balances[asset];
balance[asset] = obj;
}
console.log(balance);
});

Probably just missing a comma after the api secret.
if you're ever in trouble just start over and copy the complete example:

const binance = require('node-binance-api');
binance.options({
  APIKEY: '<key>',
  APISECRET: '<secret>',
  useServerTime: true
});

You were right, I was missing that comma. The price function involving ticker was always working perfectly. Yet, I still get an error resulting in that really long response shown above ending in:

{ date: 'Sat, 10 Feb 2018 19:46:34 GMT',
'content-type': 'application/json',
'transfer-encoding': 'chunked',
connection: 'close',
server: 'nginx',
'strict-transport-security': 'max-age=31536000; includeSubdomains',
'x-frame-options': 'SAMEORIGIN' } },
read: [Function],
body: '{"code":-1021,"msg":"Timestamp for this request was 1000ms ahead of the server's time."}' }

Update, just ran the code again....magically it works. This has happened in the past where for some reason the balance function just stopped working for a while. I really appreciate the help though.