Let’s Try Cryptocurrency Exchange API #1


1. Prepare cryptocurrency exchanges account

In this post, I’d like to share a sample of trying to get your account information from the Cryptocurrency Exchange account via their API.

This time, I tried at following two Japanese exchanges. bitFlyer is starting their service in United States. (I’m gonna share the info about other global exchanges some day, such as Poloniex, Bitfinex, Liqui, etc.)


bitFlyer ビットコインを始めるなら安心・安全な取引所で


ビットコイン取引高日本一の仮想通貨取引所 coincheck bitcoin

2. API Documents

Please refer these API documents.
bitFlyer Lightning API Document (bitFlyer Lightning API Playground)
coincheck API Document

3. Build development environment on Cloud9 easily

Cloud9 is one of the cloud services for developers. Even if you don’t have your own server or local environment on PC, you can develop and deploy your web application with only web browser! You can choose many environments, Node.js, Python(Django), Ruby, PHP, and so on. And also, you are able to use CLI(Command Line Interface, so it’s available to install additional libraries on your demand. (Although you need to input your Credit/Debit card information, it’s to avoid spams, maybe. Basically, it’s free to normal use :))

First of all, register for Cloud9, create a new workspace.

This time, we will try Node.js(JavaScript).

If you finish to make your workspace for Node.js, delete all resources(files and folders) in the project. To do it, select all resources and show the context menu with right-button-click, choose “Delete” from “File” menu on Tool bar.

After that, run following command in your shell(Terminal). “npm init”.

Then, you can see package.json file. And next, run “npm install –save request crypto”.

“–save” enable to add dependencies information into package.json and install the necessary libraries into “node_modules”.

Next, edit package.json like below.

And, make a new file named “main.js” in the project’s root. (“File” -> “New File”)

Now you are done for checking your account balance! But, did you notice the variables named “key” and “secret”? You need these information.

Public API & Private API

The APIs which don’t need authentication to call information such as market board are called “Public API”, while ones which need to authenticate are called “Private API”.
And this time, we’re using Private API.
For that, you need your own “API KEY” and “API SECRET”.

To get those, if you’re using bitFlyer, you can get from “bitFlyer Lightning” page.

Select the hamburger icon (Ξ), open “API” from menu.

And, you would be able to see like following page, then grant the permission you need. Then, keep those key and secret.
Important!! DO NOT show those info to other people!! Keep those secret!!

Keep Going!

After that, set those parameters so that you can use process.env.bfkey, and process.env.bfsecret in main.js. For that, run export command.

Kept you waiting, huh? Let’s run!!

You have a command in package.json to run, you just need run “npm start”.

Oh, wow! 80!! yen…
How pity, but you can get your trade balance!

Let’s try out coincheck too!

Alright, let’s move on to the next… How about take a look your withdrawals history.
The code is bit different, it’s similar to bitFlyer’s.
Request headers are different from bitFler’s.
ACCESS-SIGNATURE is concatenated sringified ACCESS-NONCE URL Request’s body, and signed it with HMAC-SHA256 Hash form by API Key.
I show you the code to get withdrawal history here.

And, result is…

Like this!

That’s all! We tried to get our own information with cryptocurrency exchanges’ Private APIs. And now, you might get some idea such as system trade(Algorithmic Trade)!

For more details about JavaScript(Node.js), trading, refer to some books and Udemy courses.

App Development course on Udemy

I noticed that I have registered 75 courses on Udemy… Wow.
My Recommendation is “React and Redux”, “Data Analytics”, “Deep Learning”, “Ethereum”, etc…

I’m planning to write an article about Getting board info and show it on your web browser!
Please stay tuned!!


Leave your comment.