我试图从Coinbase REST API的一个JSON负载响应中获取所有股票(货币对)及其相应的买入和卖出价数据。如果我对每个股票代码都有GET请求,则必须避免收到Coinbase API文档中提到的729错误。
我对此网址有GET请求-> https://api-public.sandbox.pro.coinbase.com/products/BTC-USD/book
哪个返回我需要BTC-USD的数据,但实际上我对交易所中列出的所有报价及其单个出价中的买入价和卖价数据感兴趣。
例如,许多其他交易所将货币代码首字母缩写替换为“ ALL”。因此,我的JSON有效负载响应如下所示:
我尝试设置一个计时器函数来一次解析3秒钟的个人报价,但这并不是从JSON获取我需要的所有数据的最快方法。
JSON响应应如下所示:
{
"ticker": [
{
"symbol": "ABBCBTC",
"24hrHigh": "0.00000850",
"last": "0.00000842",
"24hrVol": "1507399.04",
"ask": "0.0000084",
"24hrLow": "0.00000813",
"bid": "0.00000833",
"24hrAmt": "12.52040928"
},
{
"symbol": "ABTETH",
"24hrHigh": "0.001078",
"last": "0.001078",
"24hrVol": "5.27",
"ask": "0.001988",
"24hrLow": "0.000964",
"bid": "0.000983",
"24hrAmt": "0.005681"
},
{
"symbol": "ABTUSDT",
"24hrHigh": "0.212",
"last": "0.202",
"24hrVol": "944.91",
"ask": "0.203",
"24hrLow": "0.190",
"bid": "0.197",
"24hrAmt": "183.148"
},
{
"symbol": "ABYSSETH",
"24hrHigh": "0.0000500",
"last": "0.0000500",
"24hrVol": "0",
"ask": "0.000055",
"24hrLow": "0.0000500",
"bid": "0.0000301",
"24hrAmt": "0.0000000"
},
{
"symbol": "ACDCBTC",
"24hrHigh": "0.000000011",
"last": "0.000000010",
"24hrVol": "86773.47",
"ask": "0.00000001",
"24hrLow": "0.000000009",
"bid": "0.000000009",
"24hrAmt": "0.000858894"
},
{
"symbol": "ACDCUSDT",
"24hrHigh": "0.000110",
"last": "0.000107",
"24hrVol": "24011.63",
"ask": "0.000107",
"24hrLow": "0.000085",
"bid": "0.000087",
"24hrAmt": "2.088214"
},
{
"symbol": "ADDETH",
"24hrHigh": "0.000046",
"last": "0.000046",
"24hrVol": "0",
"ask": "0.000062",
"24hrLow": "0.000046",
"bid": "--",
"24hrAmt": "0.000000"
},
{
"symbol": "ADIETH",
"24hrHigh": "0.00000310",
"last": "0.00000310",
"24hrVol": "0",
"ask": "0.00000744",
"24hrLow": "0.00000310",
"bid": "0.0000031",
"24hrAmt": "0.00000000"
},
{
"symbol": "ADNBTC",
"24hrHigh": "0.0000000378",
"last": "0.0000000375",
"24hrVol": "551104713.07",
"ask": "0.0000000379",
"24hrLow": "0.0000000366",
"bid": "0.0000000367",
"24hrAmt": "20.4085431339"
}
]
}
答案 0 :(得分:2)
似乎您无法在一个通话中获得所有的报价((我不想使用Web套接字,因此我发出了一系列类似https://api.gdax.com/products/BTC-EUR/ticker之类的请求,并在它们之间有暂停。这是一种不好的做法,但我还没有时间重新构建Web套接字的基础结构。Coinbase是唯一不允许一次调用接收所有股票的交易所。我从Bittrex,Bitmex,Kraken,Bitfinex,Binance那里获得报价一口气获得所有股票都没问题。
祝你好运!