Manage Bitcoin with the Coinbase API

One of my biggest recent regrets was not pouring money into bitcoin when Kim Dotcom said we should; this was approximately 18 months ago when the bitcoin value was $170.  Today bitcoin value has topped $1000 which is why I’m kicking myself so hard.  I buy my bitcoin through Coinbase, a very user friendly, reliably vendor that makes bitcoin […]

The post Manage Bitcoin with the Coinbase API appeared first on David Walsh Blog.

One of my biggest recent regrets was not pouring money into bitcoin when Kim Dotcom said we should; this was approximately 18 months ago when the bitcoin value was $170.  Today bitcoin value has topped $1000 which is why I’m kicking myself so hard.  I buy my bitcoin through Coinbase, a very user friendly, reliably vendor that makes bitcoin seem less scary to anyone that doesn’t know the blockchain up and down.

In the past I’ve detailed a few ways to get the bitcoin value at any given time.  I wanted to write a short post bringing to light that Coinbase also has an awesome API for buying, selling, sending, and managing bitcoin via Node.js:

var Client = require('coinbase').Client; // API capabilities for your account must be enabled
// within the Coinbase account settings
var client = new Client({ 'apiKey': '#####', 'apiSecret': '#####'
}); // Get accounts and their bitcoin balance
client.getAccounts({}, (err, accounts) => { accounts.forEach(account => { console.log(`${account.name}: ${account.balance.amount} ${account.balance.currency}`); // My Wallet: 12.03 BTC });
}); // Get the current bitcoin buy price:
client.getBuyPrice({'currencyPair': 'BTC-USD'}, (err, info) => { console.log(`Buy Price: ${info.data.amount}`);
}); // Selling bitcoin
account.sell({ amount: "1", currency: "BTC" }, (err, transaction) => { console.log(`Transaction ID is: ${transaction.id}`);
}); // Sending bitcoin
account.requestMoney({ "to": "someuser@outthere.com", "amount": "1.001", "currency": "BTC", "description": "This is payment for ...."
}, (err, transaction) => { console.log(`Transaction ID is: ${transaction.id}`);
});

There are a lot of cryptic sites out there for bitcoin and alt-coin trading; most of them are probably legit but I guess I enjoy the piece of mind provided by a professional site with lots of awesome tools and loads of security features.  The fact that Coinbase also provides an excellent API is another reason I’m sticking with them.

Kim Dotcom recently said he sees bitcoin at the $2000 level by the end of 2017 and $10000 by the end of 2020.  That would be … mental.  Anyways, I get asked who I use quite a bit and, as you can see, I really love Coinbase.  Happy mining!

  • Regular Expressions for the Rest of Us

    Sooner or later you’ll run across a regular expression. With their cryptic syntax, confusing documentation and massive learning curve, most developers settle for copying and pasting them from StackOverflow and hoping they work. But what if you could decode regular expressions and harness their power? In…

  • Create a CSS Cube

    CSS cubes really showcase what CSS has become over the years, evolving from simple color and dimension directives to a language capable of creating deep, creative visuals.  Add animation and you’ve got something really neat.  Unfortunately each CSS cube tutorial I’ve read is a bit…

  • Image Manipulation with PHP and the GD Library

    Yeah, I’m a Photoshop wizard. I rock the selection tool. I crop like a farmer. I dominate the bucket tool. Hell, I even went as far as wielding the wizard wand selection tool once. …OK I’m rubbish when it comes to Photoshop.

  • JavaScript Battery API

Rojenx is a leading concept artist who work appears in games and publications

Check out his personal gallery here

In other news …

This site uses Akismet to reduce spam. Learn how your comment data is processed.