Help us understand the problem. What is going on with this article?

自動売買☓bitflyer.comでHTTP API使ってみたよ😁

自動売買☓bitflyer.comでHTTP API使ってみたよ。😁
使ってみて思ったことはリアルタイム処理とHTTP APIを混合で
使うべしだと・・・。ただ・・ビットコインの価格高いよね。
私には買えない。

http_api.js
//板情報
var F = require('./api-bitflyer.com.js');
F.Fapi.init = {
    key:"apikey",
    secret:"secretkey",
    method:"GET",
    path:"/v1/getticker",
    data:{product_code:"ETH_JPY"}
};
F.Fapi.run();
api-bitflyer.com.js
exports.Fapi = {
    init: {
        key: "",
        secret: "",
        method: "",
        path: "",
        data: ""
    },
    run: function () {
        var request = require('request');
        var crypto = require('crypto');

        var timestamp = Date.now().toString();
        var method = this.init.method;
        var path = this.init.path;
        var body = JSON.stringify(
            this.init.data
        );

        var text = timestamp + method + path + body;
        var sign = crypto.createHmac('sha256', this.init.secret).update(text).digest('hex');
        var pra = function(data){
            let str = [];
            for (const key in data) {
                if (data.hasOwnProperty(key)) {
                    str.push(key + "=" + data[key]);
                }
            }
            return "?" + str.join('&');
        };
        var options = {
            url: 'https://api.bitflyer.com' + path + (method.toUpperCase()==="POST"?"":pra(this.init.data)),
            method: method,
            body: body,
            headers: {
                'ACCESS-KEY': this.init.key,
                'ACCESS-TIMESTAMP': timestamp,
                'ACCESS-SIGN': sign,
                'Content-Type': 'application/json'
            }
        };
        request(options, function (err, response, retload) {
            console.log(retload);
        });

    }
};
question909
アイディアや個人用として使用しています。
https://taoka-toshiaki.com/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away