Skip to content

Instantly share code, notes, and snippets.

@chenosaurus
Last active April 21, 2017 09:47
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save chenosaurus/5102546 to your computer and use it in GitHub Desktop.
Save chenosaurus/5102546 to your computer and use it in GitHub Desktop.
script to buy bitcoin on coinbase
//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();
@egghaus
Copy link

egghaus commented Apr 9, 2013

they changed something. gist broken :(

@egghaus
Copy link

egghaus commented Apr 10, 2013

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

@Wingman4l7
Copy link

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