How to retrieve a list of all market pairs like ETH/BTC using Binance API?

59,304

Solution 1

You are looking for the /exchangeInfo public endpoint.

See more at https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md :

Exchange information

GET /api/v1/exchangeInfo

Current exchange trading rules and symbol information

Resulting symbols array of all coin pairs:

...
"symbols": [{
"symbol": "ETHBTC",
"status": "TRADING",
"baseAsset": "ETH",
"baseAssetPrecision": 8,
"quoteAsset": "BTC",
"quotePrecision": 8,
"orderTypes": [
  // These are defined in the `ENUM definitions` section under `Order types (orderTypes)`.
  // All orderTypes are optional.
],
"icebergAllowed": false,
"filters": [
  // There are defined in the `Filters` section.
  // All filters are optional.
]
}]
...

Solution 2

I think it would be easier to create dump of the coin list and place here for new developers

["BTC","LTC","ETH","NEO","BNB","QTUM","EOS","SNT","BNT","GAS","BCC","USDT","HSR","OAX","DNT","MCO","ICN","ZRX","OMG","WTC","YOYO","LRC","TRX","SNGLS","STRAT","BQX","FUN","KNC","CDT","XVG","IOTA","SNM","LINK","CVC","TNT","REP","MDA","MTL","SALT","NULS","SUB","STX","MTH","ADX","ETC","ENG","ZEC","AST","GNT","DGD","BAT","DASH","POWR","BTG","REQ","XMR","EVX","VIB","ENJ","VEN","ARK","XRP","MOD","STORJ","KMD","RCN","EDO","DATA","DLT","MANA","PPT","RDN","GXS","AMB","ARN","BCPT","CND","GVT","POE","BTS","FUEL","XZC","QSP","LSK","BCD","TNB","ADA","LEND","XLM","CMT","WAVES","WABI","GTO","ICX","OST","ELF","AION","WINGS","BRD","NEBL","NAV","VIBE","LUN","TRIG","APPC","CHAT","RLC","INS","PIVX","IOST","STEEM","NANO","AE","VIA","BLZ","SYS","RPX","NCASH","POA","ONT","ZIL","STORM","XEM","WAN","WPR","QLC","GRS","CLOAK","LOOM","BCN","TUSD","ZEN","SKY","THETA","IOTX","QKC","AGI","NXS","SC","NPXS","KEY","NAS","MFT","DENT","IQ","ARDR","HOT","VET","DOCK","POLY","VTHO","ONG","PHX","HC","GO","PAX","RVN","DCR","USDC","MITH","BCHABC","BCHSV","REN","BTT","USDS","FET","TFUEL","CELR","MATIC","ATOM","PHB","ONE","FTM","BTCB","USDSB","CHZ","COS","ALGO","ERD","DOGE","BGBP","DUSK","ANKR","WIN","TUSDB","COCOS","PERL","TOMO","BUSD","BAND","BEAM","HBAR","XTZ","NGN","DGB","NKN","GBP","EUR","KAVA","RUB","UAH","ARPA","TRY","CTXC","AERGO","BCH","TROY","BRL","VITE","FTT","AUD","OGN","DREP","BULL","BEAR","ETHBULL","ETHBEAR","XRPBULL","XRPBEAR","EOSBULL","EOSBEAR","TCT","WRX","LTO","ZAR","MBL","COTI","BKRW","BNBBULL","BNBBEAR","HIVE","STPT","SOL","IDRT","CTSI","CHR","BTCUP","BTCDOWN","HNT","JST","FIO","BIDR","STMX","MDT","PNT","COMP","IRIS","MKR","SXP","SNX","DAI","ETHUP","ETHDOWN","ADAUP","ADADOWN","LINKUP","LINKDOWN","DOT","RUNE","BNBUP","BNBDOWN","XTZUP","XTZDOWN","AVA","BAL","YFI","SRM","ANT","CRV","SAND","OCEAN","NMR","LUNA","IDEX","RSR","PAXG","WNXM","TRB","EGLD","BZRX","WBTC","KSM","SUSHI","YFII","DIA","BEL","UMA","EOSUP","TRXUP","EOSDOWN","TRXDOWN","XRPUP","XRPDOWN","DOTUP","DOTDOWN","NBS","WING","SWRV","LTCUP","LTCDOWN","CREAM","UNI","OXT","SUN","AVAX","BURGER","BAKE","FLM","SCRT","XVS","CAKE","SPARTA","UNIUP","UNIDOWN","ALPHA","ORN","UTK","NEAR","VIDT","AAVE","FIL","SXPUP","SXPDOWN","INJ","FILDOWN","FILUP","YFIUP","YFIDOWN","CTK","EASY","AUDIO","BCHUP","BCHDOWN","BOT","AXS","AKRO","HARD","KP3R","RENBTC","SLP","STRAX","UNFI","CVP","BCHA","FOR","FRONT","ROSE","HEGIC","AAVEUP","AAVEDOWN","PROM","BETH","SKL","GLM","SUSD","COVER","GHST","SUSHIUP","SUSHIDOWN","XLMUP","XLMDOWN","DF","JUV","PSG","BVND","GRT","CELO","TWT","REEF","OG","ATM","ASR","1INCH","RIF","BTCST","TRU","DEXE","CKB","FIRO","LIT","PROS","VAI","SFP","FXS","DODO","AUCTION","UFT","ACM","PHA","TVK","BADGER","FIS","OM","POND","ALICE","DEGO","BIFI","LINA"]

Solution 3

For python users that ended up here after googling "binance api trade pairs":

from binance.client import Client

api_key = "xxx"
api_secret = "xxx"

client = Client(api_key, api_secret)
exchange_info = client.get_exchange_info()
for s in exchange_info['symbols']:
    print(s['symbol'])

ETHBTC
LTCBTC
BNBBTC
NEOBTC
QTUMETH
EOSETH
SNTETH
BNTETH
...

Solution 4

Just change the "quote" variable with the quote asset you want. Then after you launch the script, you will get a "allTargets" file with all the base assets

var request = require('request');
var fs = require('fs')
var quote="USDT"
var options = {
  'method': 'GET',
  'url': 'https://api.binance.com/api/v1/exchangeInfo',
  'headers': {
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  //console.log(JSON.parse(response.body));
  var symbols = JSON.parse(response.body).symbols
  var justUSDTpairs = symbols.map((x)=>{
    if(x.quoteAsset.includes(quote)){
      return x.baseAsset
    }
  }).filter((x)=>{if(x){return x}})
  fs.writeFileSync('allTargets',JSON.stringify(justUSDTpairs))
}); 

Solution 5

I would like to update the code provided by Emad above.

from binance.client import Client
import pandas as pd

api_key = 'Your Api Key'
api_secret = 'Your Secret Key'

client = Client(api_key, api_secret)
symbols = client.get_exchange_info()
df = pd.DataFrame(symbols['symbols'])

li = []

for index, data in df.iterrows():
    if data['isMarginTradingAllowed'] == True:
        li.append(data['symbol'])

fdf = pd.DataFrame(li)
fdf.to_excel('Margin Trading Pairs.xlsx', index=False)
Share:
59,304
V.Spock
Author by

V.Spock

Updated on December 29, 2021

Comments

  • V.Spock
    V.Spock over 2 years

    I am working on a project relevant to crypto trading where I need to select a market pair of Binance Exchange and based on the pair choice I have to show various results like current price, 24 Hr price change, 24 Hr Volume and last 10 trade history of that market pair. I have gone through Binance Rest API Docs: https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md ,and can't find the endpoint which can help me retrieve a list of market pairs. Is there any documentation I am unaware about?

    Thanks.