furkanbicak
furkanbicak

Reputation: 33

How can I get all coins in USD parity to the Binance API?

I need binance data to build a mobile app. Only USDT pairs are sufficient. In the link below it takes all trading pairs, but I only want USDT pairs. Which link should I use for this?

https://api.binance.com/api/v3/ticker/price

Upvotes: 2

Views: 7149

Answers (2)

FlorinelChis
FlorinelChis

Reputation: 1478

There is a python binance client library and you can do check the list of tickers which tickers are quoted in USDT (and status is trading):

from binance.client import Client
client = Client()
info = client.get_exchange_info()
for c in info['symbols']:
    if c['quoteAsset']=='USDT' and c['status']=="TRADING":
        print(c['symbol'])

Upvotes: 1

Nand0san
Nand0san

Reputation: 511

You can use the Binance Exchange API. There is no need for registering.

The used API call is this: https://api.binance.com/api/v3/exchangeInfo

I recomend you use google colab and python, or any other python resource:

import requests

def get_response(url):
    response = requests.get(url)
    response.raise_for_status()  # raises exception when not a 2xx response
    if response.status_code != 204:
        return response.json()

def get_exchange_info():
    base_url = 'https://api.binance.com'
    endpoint = '/api/v3/exchangeInfo'
    return get_response(base_url + endpoint)

def create_symbols_list(filter='USDT'):
    rows = []
    info = get_exchange_info()
    pairs_data = info['symbols']
    full_data_dic = {s['symbol']: s for s in pairs_data if filter in s['symbol']}
    return full_data_dic.keys()

create_symbols_list('USDT')

Result:

['BTCUSDT', 'ETHUSDT', 'BNBUSDT', 'BCCUSDT', 'NEOUSDT', 'LTCUSDT',...

The api call brings you a very large response fill with with interesting data about the exchange. In the function create_symbols_list you get all this data in the full_data_dic dictionary.

Upvotes: 1

Related Questions