REST API for interacting with the Binance trading platform
- Create account on the Binance Spot Test Network: https://testnet.binance.vision/
- Generate API keys
- Create account on the Binance Futures Test Network: https://testnet.binancefuture.com/
- Copy API keys from API Keys tab
- Rename config-sample.js to config.js and input the API keys
npm install
npm start
URL: /order
Method: GET
Query Parameters:
user
(required): User identifiersymbol
(required): Trading pair symbol (e.g., BTCUSDT)side
(required): Order side (BUY or SELL)quantity
(required): Order quantitymarket
(optional): Market type (spot
orfutures
, default isspot
)environment
(optional): Environment type (testnet
orlive
, default istestnet
)
Response:
- JSON object containing the order response
Example:
curl "http://localhost:3000/order?user=user1&symbol=BTCUSDT&side=BUY&quantity=0.01"
URL: /account
Method: GET
Query Parameters:
user
(required): User identifiermarket
(optional): Market type (spot
orfutures
, default isspot
)environment
(optional): Environment type (testnet
orlive
, default istestnet
)
Response:
- JSON object containing the account data
Example:
curl "http://localhost:3000/account?user=user1"
URL: /balance
Method: GET
Query Parameters:
user
(required): User identifiersymbol
(required): Asset symbol (e.g., BTC)market
(optional): Market type (spot
orfutures
, default isspot
)environment
(optional): Environment type (testnet
orlive
, default istestnet
)
Response:
- JSON object containing the asset balance
Example:
curl "http://localhost:3000/balance?user=user1&symbol=BTC"
URL: /price
Method: GET
Query Parameters:
user
(required): User identifiersymbol
(required): Trading pair symbol (e.g., BTCUSDT)market
(optional): Market type (spot
orfutures
, default isspot
)environment
(optional): Environment type (testnet
orlive
, default istestnet
)
Response:
- JSON object containing the ticker price
Example:
curl "http://localhost:3000/balance?user=user1&symbol=BTC"
URL: /historical-price
Fetch a single price at a specific datetime.
Method: GET
Query Parameters:
user
(required): User identifier.symbol
(required): Trading pair symbol (e.g., BTCUSDT).datetime
(required): The specific datetime in YYYYMMDDHHmm format.interval
(optional): Data interval (1m, 5m, 15m, 30m, 1h, 4h, 1d, default is 1h).market
(optional): Market type (spot
orfutures
, default isspot
).environment
(optional): Environment type (testnet
orlive
, default islive
).
Example:
GET /historical-price?user=testUser&symbol=BTCUSDT&datetime=202401020000&interval=1h
URL: /historical-price-range
Fetch historical price data for a specific trading pair over a time range.
Method: GET
Query Parameters:
user
(required): User identifier.symbol
(required): Trading pair symbol (e.g., BTCUSDT).startTime
(required): Start time in YYYYMMDDHHmm format.endTime
(required): End time in YYYYMMDDHHmm format.interval
(optional): Data interval (1m, 5m, 15m, 30m, 1h, 4h, 1d, default is 1h).market
(optional): Market type (spot
orfutures
, default isspot
).environment
(optional): Environment type (testnet
orlive
, default islive
). |
Example:
GET /historical-price-range?user=yourBinanceUser&symbol=BTCUSDT&startTime=202401010000&endTime=202401020000&interval=1h&market=spot&environment=live