-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* v3.0.0-rc.2 release * update change log date
- Loading branch information
Showing
11 changed files
with
110 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,17 @@ | ||
'use strict' | ||
|
||
const fs = require('fs') | ||
const Spot = require('../../../src/spot') | ||
|
||
let apiKey = '' | ||
let apiSecret = '' | ||
let client | ||
const apiKey = '' | ||
const apiSecret = '' | ||
|
||
// baseURL is used to set which market you wish to send the request to. | ||
// Please make sure the api key/secret is consistent with the baseURL, It won't work if you send request to production site with testnet api key. | ||
// Please make sure the api key/secret is consistent with the baseURL. It won't work if you send request to production site with testnet api key. | ||
// https://api.binance.com is for production. | ||
// https://testnet.binance.vision is the spot testnet base url | ||
|
||
// timeout is another optional value in milliseconds, that how long the request is allowed to executed. | ||
|
||
client = new Spot(apiKey, apiSecret, { baseURL: 'https://testnet.binance.vision', timeout: 1000 }) | ||
const client = new Spot(apiKey, apiSecret, { baseURL: 'https://testnet.binance.vision', timeout: 1000 }) | ||
|
||
client.account() | ||
.then(response => client.logger.log(response.data)) | ||
.catch(error => client.logger.error(error.message)) | ||
|
||
// Below example shows how to sign the request with RSA key. You will have to a few steps: | ||
// 1. Have your RSA keys ready. | ||
// 2. Login to Binance.com to register your public key. | ||
// 3. Save the API Key that is generated from UI, then you are ready to go. | ||
apiKey = 'the_api_key' | ||
apiSecret = '' // Not required for RSA signature. | ||
|
||
// load private key | ||
const privateKey = fs.readFileSync('/Users/liangshi/ssl/private_key_encrypted.pem') | ||
|
||
client = new Spot(apiKey, apiSecret, { | ||
baseURL: 'https://testnet.binance.vision', // This URL is for testnet; Remove it for production. | ||
privateKey, | ||
privateKeyPassphrase: 'private_key_password', // only used for encrypted key | ||
timeout: 1000 | ||
}) | ||
|
||
client.account() | ||
.then(response => client.logger.log(response.data)) | ||
.catch(error => client.logger.error(error)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict' | ||
|
||
const fs = require('fs') | ||
const Spot = require('../../../src/spot') | ||
const PrivateKeyAlgo = require('../../../src/helpers/privateKeyAlgo') | ||
|
||
// Please make sure the api key/secret is consistent with the baseURL. It won't work if you send request to production site with testnet api key. | ||
// https://api.binance.com is for production. | ||
// https://testnet.binance.vision is the spot testnet base url | ||
|
||
// Below example shows how to sign the request with key. You will have to a few steps: | ||
// 1. Have your Ed25519 key ready. | ||
// 2. Login to Binance.com to register your public key. | ||
// 3. Save the API Key that is generated from UI, then you are ready to go. | ||
const apiKey = 'the api key' | ||
|
||
// load private key | ||
const privateKey = fs.readFileSync('/Users/john/ed25519.pem') | ||
|
||
const client = new Spot(apiKey, null, { | ||
baseURL: 'https://testnet.binance.vision', // This URL is for testnet; Remove it for production. | ||
privateKey, | ||
privateKeyAlgo: PrivateKeyAlgo.ED25519, // specific the key algo | ||
timeout: 1000 | ||
}) | ||
|
||
client.account() | ||
.then(response => client.logger.log(response.data)) | ||
.catch(error => client.logger.error(error)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict' | ||
|
||
const fs = require('fs') | ||
const Spot = require('../../../src/spot') | ||
|
||
// Please make sure the api key/secret is consistent with the baseURL. It won't work if you send request to production site with testnet api key. | ||
// https://api.binance.com is for production. | ||
// https://testnet.binance.vision is the spot testnet base url | ||
|
||
// Below example shows how to sign the request with RSA key. You will have to a few steps: | ||
// 1. Have your RSA keys ready. | ||
// 2. Login to Binance.com to register your public key. | ||
// 3. Save the API Key that is generated from UI, then you are ready to go. | ||
const apiKey = 'the api key' | ||
const apiSecret = '' // Not required for RSA signature. | ||
|
||
// load private key | ||
const privateKey = fs.readFileSync('/Users/john/private_key_encrypted.pem') | ||
|
||
const client = new Spot(apiKey, apiSecret, { | ||
baseURL: 'https://testnet.binance.vision', // This URL is for testnet; Remove it for production. | ||
privateKey, | ||
privateKeyPassphrase: 'password', // only used for encrypted key | ||
timeout: 1000 | ||
}) | ||
|
||
client.account() | ||
.then(response => client.logger.log(response.data)) | ||
.catch(error => client.logger.error(error)) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict' | ||
|
||
const Error = require('../error/error') | ||
|
||
class ConnectorClientError extends Error { | ||
constructor (errorMessage) { | ||
super(errorMessage) | ||
this.name = 'ConnectorClientError' | ||
} | ||
} | ||
|
||
module.exports = ConnectorClientError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const PrivateKeyAlgo = { | ||
RSA: 'RSA', | ||
ED25519: 'Ed25519' | ||
} | ||
|
||
module.exports = PrivateKeyAlgo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
'use strict' | ||
|
||
module.exports.PrivateKeyAlgo = require('./helpers/privateKeyAlgo') | ||
module.exports.Spot = require('./spot') | ||
module.exports.WebsocketStream = require('./websocketStream') | ||
module.exports.WebsocketAPI = require('./websocketAPI') |