【问题标题】:How can I get all coins in USD parity to the Binance API?如何将美元平价的所有硬币获取到 Binance API?
【发布时间】:2021-07-30 00:34:01
【问题描述】:

我需要币安数据来构建移动应用。只有 USDT 对就足够了。在下面的链接中,它需要所有交易对,但我只想要 USDT 对。我应该使用哪个链接?

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

【问题讨论】:

标签: api binance binance-smart-chain binance-api-client


【解决方案1】:

您可以使用Binance Exchange 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 调用会为您带来非常大的响应,其中包含有关交易所的有趣数据。在 create_symbols_list 函数中,您可以在 full_data_dic 字典中获取所有这些数据。

【讨论】:

    猜你喜欢
    • 2021-05-17
    • 1970-01-01
    • 2022-11-18
    • 2022-01-14
    • 1970-01-01
    • 2010-11-09
    • 2021-05-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多