Skip to content

Commit

Permalink
Rest Endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
bmino committed May 11, 2020
1 parent a490679 commit 0558bb0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion examples/experiments.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const WebSocket = require('ws');
let streams = [];
let markets = [];
let prevDay = await axios.get('https://api.binance.com/api/v1/ticker/24hr');
let prevDay = await axios.get('https://api.binance.com/api/v3/ticker/24hr');
for ( let obj of prevDay.data ) {
markets.push(obj.symbol);
streams.push(obj.symbol.toLowerCase()+'@aggTrade');
Expand Down
34 changes: 17 additions & 17 deletions node-binance-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ let api = function Binance( options = {} ) {
if ( typeof urls.fstreamSingle === 'string' ) fstreamSingle = urls.fstreamSingle;
}
if ( Binance.options.useServerTime ) {
apiRequest( base + 'v1/time', {}, function ( error, response ) {
apiRequest( base + 'v3/time', {}, function ( error, response ) {
Binance.info.timeOffset = response.serverTime - new Date().getTime();
//Binance.options.log("server time set: ", response.serverTime, Binance.info.timeOffset);
if ( callback ) callback();
Expand Down Expand Up @@ -2054,12 +2054,12 @@ let api = function Binance( options = {} ) {
resolve( response );
}
}
publicRequest( base + 'v1/depth', { symbol: symbol, limit: limit }, function ( error, data ) {
publicRequest( base + 'v3/depth', { symbol: symbol, limit: limit }, function ( error, data ) {
return callback.call( this, error, depthData( data ), symbol );
} );
} )
} else {
publicRequest( base + 'v1/depth', { symbol: symbol, limit: limit }, function ( error, data ) {
publicRequest( base + 'v3/depth', { symbol: symbol, limit: limit }, function ( error, data ) {
return callback.call( this, error, depthData( data ), symbol );
} );
}
Expand Down Expand Up @@ -2174,12 +2174,12 @@ let api = function Binance( options = {} ) {
resolve( response );
}
}
publicRequest( base + 'v1/ticker/24hr', input, ( error, data ) => {
publicRequest( base + 'v3/ticker/24hr', input, ( error, data ) => {
return callback.call( this, error, data, symbol );
} );
} )
} else {
publicRequest( base + 'v1/ticker/24hr', input, ( error, data ) => {
publicRequest( base + 'v3/ticker/24hr', input, ( error, data ) => {
return callback.call( this, error, data, symbol );
} );
}
Expand All @@ -2200,10 +2200,10 @@ let api = function Binance( options = {} ) {
resolve( response );
}
}
publicRequest( base + 'v1/exchangeInfo', {}, callback );
publicRequest( base + 'v3/exchangeInfo', {}, callback );
} )
} else {
publicRequest( base + 'v1/exchangeInfo', {}, callback );
publicRequest( base + 'v3/exchangeInfo', {}, callback );
}
},

Expand Down Expand Up @@ -2511,14 +2511,14 @@ let api = function Binance( options = {} ) {
resolve( response );
}
}
apiRequest( base + 'v1/time', {}, function ( error, response ) {
apiRequest( base + 'v3/time', {}, function ( error, response ) {
Binance.info.timeOffset = response.serverTime - new Date().getTime();
//Binance.options.log("server time set: ", response.serverTime, Binance.info.timeOffset);
callback( error, response );
} );
} )
} else {
apiRequest( base + 'v1/time', {}, function ( error, response ) {
apiRequest( base + 'v3/time', {}, function ( error, response ) {
Binance.info.timeOffset = response.serverTime - new Date().getTime();
//Binance.options.log("server time set: ", response.serverTime, Binance.info.timeOffset);
callback( error, response );
Expand All @@ -2541,10 +2541,10 @@ let api = function Binance( options = {} ) {
resolve( response );
}
}
apiRequest( base + 'v1/time', {}, callback );
apiRequest( base + 'v3/time', {}, callback );
} )
} else {
apiRequest( base + 'v1/time', {}, callback );
apiRequest( base + 'v3/time', {}, callback );
}
},

Expand All @@ -2566,10 +2566,10 @@ let api = function Binance( options = {} ) {
resolve( response );
}
}
marketRequest( base + 'v1/aggTrades', parameters, callback );
marketRequest( base + 'v3/aggTrades', parameters, callback );
} )
} else {
marketRequest( base + 'v1/aggTrades', parameters, callback );
marketRequest( base + 'v3/aggTrades', parameters, callback );
}
},

Expand Down Expand Up @@ -2617,10 +2617,10 @@ let api = function Binance( options = {} ) {
resolve( response );
}
}
marketRequest( base + 'v1/historicalTrades', parameters, callback );
marketRequest( base + 'v3/historicalTrades', parameters, callback );
} )
} else {
marketRequest( base + 'v1/historicalTrades', parameters, callback );
marketRequest( base + 'v3/historicalTrades', parameters, callback );
}
},

Expand Down Expand Up @@ -2685,12 +2685,12 @@ let api = function Binance( options = {} ) {
resolve( response );
}
}
publicRequest( base + 'v1/klines', params, function ( error, data ) {
publicRequest( base + 'v3/klines', params, function ( error, data ) {
return callback.call( this, error, data, symbol );
} );
} )
} else {
publicRequest( base + 'v1/klines', params, function ( error, data ) {
publicRequest( base + 'v3/klines', params, function ( error, data ) {
return callback.call( this, error, data, symbol );
} );
}
Expand Down

0 comments on commit 0558bb0

Please sign in to comment.