作为coinbase-api中的一个例子,我可以这样获得加密货币的价格:
const eth_eur = await publicClient.getProductOrderBook('ETH-EUR', { level: 1 });
正如您所看到的,我需要对cryptocurrency - eur,这很重要。那么,如何使用二进制api来实现呢?
我试着用这样的方法:
const price = await binance.futuresFundingRate("ETHUSDT");
但这不是我需要的。我需要欧元的价格。
发布于 2021-09-21 09:56:42
对于与EUR成对的基本货币,您可以使用“当前平均价格”端点(EUR)。
示例:
const axios = require('axios');
axios.get('https://api.binance.com/api/v3/avgPrice?symbol=BTCEUR').then(response => {
const body = response.data;
console.log(body.price);
});发布于 2022-05-02 18:30:37
您可以很容易地获得汇率与超表面npm包。
示例
npm install @superfaceai/one-sdk
npx @superfaceai/cli install crypto/exchange-rate
const { SuperfaceClient } = require("@superfaceai/one-sdk");
const sdk = new SuperfaceClient();
async function run() {
// Load the installed profile
const profile = await sdk.getProfile("crypto/exchange-rate");
// Use the profile
const result = await profile.getUseCase("GetExchangeRate").perform({
from: "ETH",
to: "EUR",
});
console.log(result.unwrap());
}
run();
https://stackoverflow.com/questions/69266793
复制相似问题