JavaScriptで取引所から価格を取得します。
まずは公式からのコピペ
公式サイトの方法
1 |
npm i -D request |
1 2 3 4 5 6 7 8 |
var request = require('request'); var endPoint = 'https://api.coin.z.com/public'; var path = '/v1/ticker?symbol=BTC'; request(endPoint + path, function (err, response, payload) { console.log(JSON.stringify(JSON.parse(payload), null, 2)); }); |
node-fetch版
1 |
npm i -D node-fetch |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
var endPoint = 'https://api.coin.z.com/public'; var path = '/v1/ticker?symbol=BTC'; const fetch = require('node-fetch'); (async () => { try { const response = await fetch(endPoint + path) const json = await response.json() console.log(JSON.stringify(json, null, 2)); } catch (error) { console.log(error.response.body); } })(); |
pybit 最新版にコードを変更しました。コードとrequirements.tx…
お返事ありがとうございます。はい。pybit==2.3.0になっております。
コードはあっていると思います。rewuirements.txtは「pybit==…
誠に有難うございます。確認しました出力ok出まして$ okと表示されました。 こ…
https://web-lukes.info/kasoutuuka-nyumon…