Mar 11, 2015

Official node.js API Wrapper

As announced we published the official node.js API Wrapper.

var fs = require('fs');
var cloudconvert = new (require('cloudconvert'))('your_api_key');
 
cloudconvert.convert({
    inputformat: 'png',
    outputformat: 'jpg',
    file: fs.createReadStream('tests/input.png'),
    converteroptions: {
        quality : 75,
    }
}).on('error', function(err) {
    console.error('Failed: ' + err);
}).on('finished', function(data) {
    console.log('Done: ' + data.message);
    this.pipe(fs.createWriteStream('out.jpg'));
}).on('downloaded', function(destination) {
    console.log('Downloaded to: ' + destination.path);
});