Giter Club home page Giter Club logo

binance-trading-api's Introduction

REST API for interacting with the Binance trading platform

prerequisites

spot market

  1. Create account on the Binance Spot Test Network: https://testnet.binance.vision/
  2. Generate API keys

futures market

  1. Create account on the Binance Futures Test Network: https://testnet.binancefuture.com/
  2. Copy API keys from API Keys tab

config file

  1. Rename config-sample.js to config.js and input the API keys

install NodeJS packages

npm install

start API server

npm start

Endpoints

Place Order

URL: /order

Method: GET

Query Parameters:

  • user (required): User identifier
  • symbol (required): Trading pair symbol (e.g., BTCUSDT)
  • side (required): Order side (BUY or SELL)
  • quantity (required): Order quantity
  • market (optional): Market type (spot or futures, default is spot)
  • environment (optional): Environment type (testnet or live, default is testnet)

Response:

  • JSON object containing the order response

Example:

curl "http://localhost:3000/order?user=user1&symbol=BTCUSDT&side=BUY&quantity=0.01"

Fetch Account Data

URL: /account

Method: GET

Query Parameters:

  • user (required): User identifier
  • market (optional): Market type (spot or futures, default is spot)
  • environment (optional): Environment type (testnet or live, default is testnet)

Response:

  • JSON object containing the account data

Example:

curl "http://localhost:3000/account?user=user1"

Check Balance

URL: /balance

Method: GET

Query Parameters:

  • user (required): User identifier
  • symbol (required): Asset symbol (e.g., BTC)
  • market (optional): Market type (spot or futures, default is spot)
  • environment (optional): Environment type (testnet or live, default is testnet)

Response:

  • JSON object containing the asset balance

Example:

curl "http://localhost:3000/balance?user=user1&symbol=BTC"

Retrieve Ticker Price

URL: /price

Method: GET

Query Parameters:

  • user (required): User identifier
  • symbol (required): Trading pair symbol (e.g., BTCUSDT)
  • market (optional): Market type (spot or futures, default is spot)
  • environment (optional): Environment type (testnet or live, default is testnet)

Response:

  • JSON object containing the ticker price

Example:

curl "http://localhost:3000/balance?user=user1&symbol=BTC"

Historical Price

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 or futures, default is spot).
  • environment (optional): Environment type (testnet or live, default is live).

Example:

GET /historical-price?user=testUser&symbol=BTCUSDT&datetime=202401020000&interval=1h

Historical Price Range

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 or futures, default is spot).
  • environment (optional): Environment type (testnet or live, default is live). |

Example:

GET /historical-price-range?user=yourBinanceUser&symbol=BTCUSDT&startTime=202401010000&endTime=202401020000&interval=1h&market=spot&environment=live

binance-trading-api's People

Watchers

Julien Regnault avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.