-
Notifications
You must be signed in to change notification settings - Fork 1
Home
This package provides a unified command-line interface to interact with Binance API (https://binance-docs.github.io/apidocs)
ℹ️ This is an unofficial package, and this project is not related or affiliated with Binance.
🚨 Use at your own risk.
You should have an active Binance account to create a valid API key and secret key.
You can follow this step-by-step guide provided by Binance:
https://www.binance.com/en/support/faq/360002502072
Before using BNC CLI, you need to tell it about your credentials. You can do this in several ways:
- Configuration file (recommended)
- Environment variables
The quickest way to get started is to run the bnc credentials add
command:
$ bnc credentials add --api_key="YOUR_API_KEY" --secret="YOUR_SECRET_KEY"
Binance CLI's credentials added successfully.
When you add your credentials using the previous command, it will create an INI formatted file called credentials
under ~/.bnc
directory with the following structure:
[api_credentials]
bnc_cli_api_key = <YOUR_API_KEY>
bnc_cli_secret_key = <YOUR_SECRET_KEY>
To use environment variables, do the following:
$ export BNC_CLI_API_KEY=<YOUR_API_KEY>
$ export BNC_CLI_SECRET_KEY=<YOUR_SECRET_KEY>
An BNC CLI command has the following structure:
$ bnc <command> [options and parameters]
$ bnc <command> <group_commands> <command> [options and parameters]
To view help documentation, use one of the following:
$ bnc --help
$ bnc <command> --help
$ bnc <command> <group_commands> --help
$ bnc <command> <group_commands> <command> --help
To get the version of the BNC CLI:
$ bnc --version
To turn on verbose output:
$ bnc --verbose <command>
$ bnc --verbose <group_commands> <command>
The default output for commands is currently JSON.
There is also an ASCII table format available and YAML. You can select either style with the --output
option at the root command bnc.
$ bnc spot account_info
{
"makerCommission": 0,
"takerCommission": 0,
"buyerCommission": 0,
"sellerCommission": 0,
"canTrade": true,
"canWithdraw": false,
"canDeposit": false,
"updateTime": 1616376905442,
"accountType": "SPOT",
"balances": [
{
"asset": "BNB",
"free": "1000.00000000",
"locked": "0.00000000"
},
{
"asset": "BTC",
"free": "0.98181601",
"locked": "0.00000000"
}
],
"permissions": [
"SPOT"
]
}
$ bnc --output=yaml spot account_info
makerCommission: 0
takerCommission: 0
buyerCommission: 0
sellerCommission: 0
canTrade: true
canWithdraw: false
canDeposit: false
updateTime: 1616376905442
accountType: SPOT
balances:
- asset: BNB
free: '1000.00000000'
locked: '0.00000000'
- asset: BTC
free: '0.98181601'
locked: '0.00000000'
permissions:
- SPOT
Some commands have an --query
option that allows extracting and transforming elements from a JSON. It is very useful on occasions where you need to filter a very long response from Binance API. For more information on the expression language used for this option, you can read the JMESPath Tutorial
Add example here
If this package helped you out. Feel free to donate.
This project is linked to a Brave verified creator account, so you can set a monthly contribution (with BAT token) to this project using your Brave browser.
- BNB (BEP20): 0xDD460d5d6688beC66E37A6b7c8f5b3f801603537
- CAKE (BEP20): 0xDD460d5d6688beC66E37A6b7c8f5b3f801603537
- BUSD (BEP20): 0xDD460d5d6688beC66E37A6b7c8f5b3f801603537
- ETH (ERC20): 0xDD460d5d6688beC66E37A6b7c8f5b3f801603537
- BTC: 15yLrtPkRbxd5sEBWHGUCzYXraVA78RFz5
Not your favorite crypto address listed?
Fill an issue, and we will add the crypto address.