簡體   English   中英

我怎樣才能獲得與 Binance API 的美元平價的所有硬幣?

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

我需要幣安數據來構建移動應用程序。 只有 USDT 對就足夠了。 在下面的鏈接中,它需要所有交易對,但我只想要 USDT 對。 我應該使用哪個鏈接?

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

您可以使用幣安交易所 API 無需注冊。

使用的 API 調用是這樣的: https://api.binance.com/api/v3/exchangeInfo

我建議您使用 google colab 和 python 或任何其他 python 資源:

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')

結果

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

api 調用會為您帶來非常大的響應,其中包含有關交易所的有趣數據。 在 function create_symbols_list中,您可以在full_data_dic字典中獲得所有這些數據。

有一個 python幣安客戶端庫,您可以查看以 USDT 報價的代碼列表(狀態為交易):

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'])

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM