区块链开发入门02 使用币安API获取代币价格

Play Video

https://github.com/binance/binance-connector-node

const { Spot } = require('@binance/connector')

const client = new Spot()

client.tickerPrice('SHIBUSDT').then(response => console.log(response.data))

更新

由于现货价格接口不需要认证 所以可以省略key和secret

代理问题

推荐在外国主机上运行代码

本地要走sock5代理 应该要改造一下connector里的axios实例化代码

https://github.com/binance/binance-connector-node/blob/54368ccfde50055cf02ae9dae883d61ff5e560a3/src/helpers/utils.js#L38
https://github.com/binance/binance-connector-node/blob/54368ccfde50055cf02ae9dae883d61ff5e560a3/src/helpers/utils.js#L38

具体参考 这里