Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

script to buy bitcoin on coinbase

View buy.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
//you will need to install node.js and restler first
//npm install restler
 
//run with the following command
// node buy.js
 
var sys = require('util'),
rest = require('restler');
 
//set these to your coinbase API key & the amount you want to buy
var apiKey = 'api_key';
var quantity = 10;
 
var jsonData = { qty: quantity };
 
function onComplete(data, res) {
console.log(new Date().toString());
if (!data.success) {
console.log( data.errors);
setTimeout(buy, 5000);
} else {
console.log("SUCCESS!");
}
 
};
 
function buy() {
rest.postJson('https://coinbase.com/api/v1/buys?api_key=' + apiKey, jsonData).on('complete', onComplete);
}
 
buy();

they changed something. gist broken :(

so glad this was broken. -$110 drop today. rofl

Not broken per se; you probably ran into that "check this box to buy BTC at a future market price since the 24-hour rolling limit has been hit" situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.