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);
        });

    }
};
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
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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
ユーザーは見つかりませんでした