chute

API client for Chute platform.

Chute

Chute makes it possible for you to easily organize, store and serve photos and videos. This NPM package provides you with a wrapper for the Chute API. You can learn more about Chute http://getchute.com and explore the API at http://picture.io.

Installation

npm install chute

Getting Started

  1. Sign up for an account at Chute
  2. Install this library
  3. Read the API docs for better understanding
  4. Read the annotated source for even better understanding of what's under the hood

Usage

Initialize:

var Chute = require('chute');
var client = new Chute;
client.set({
    token: 'access token',
    id: 'app id'
});

Chutes allow you to manage sets of photos - you can think of them like albums.

Find:

// all chutes found 
client.chutes.all(function(errchutes){
    for(var i = 0; i < chutes.length; i++) {
        chute.id;
    }
});
 
// chute with ID=12345 found 
client.chutes.find({ id: 12345 }, function(errchute){
    chute.id;
});
 
// chute with ID=12345 found with contributors list inside 
client.chutes.find({ id: 12345, contributors: true }, function(errchute){
    chute.contributors;
});
 
// chute with ID=12345 found with members list inside 
client.chutes.find({ id: 12345, members: true }, function(errchute){
    chute.members;
});
 
// chute with ID=12345 found with parcels list inside 
client.chutes.find({ id: 12345, parcels: true }, function(errchute){
    chute.parcels;
});
 
// chute with ID=12345 found with everything inside 
client.chutes.find({
    id: 12345,
    contributors: true,
    members: true,
    parcels: true
}, function(errchute){
    chute.id;
});

Create:

// chute created 
client.chutes.create({ name: 'Testing' }, function(errchute){
    chute.id;
});

Update:

// chute with ID=235345 changed name to 'New name' 
client.chutes.update({ id: 235345, name: 'New name' }, function(errchute){
    chute.id;
});

Remove:

// chute with ID=12345 removed 
client.chutes.remove({ id: 12345 }, function(err){
    
});

Assets represent photos and videos contained within a Chute.

Find:

// asset with ID=12345 found 
client.assets.find({ id: 12345 }, function(errasset){
    asset.id;
});
 
// asset with ID=12345 found with comments inside 
client.assets.find({ id: 12345, comments: true }, function(errasset){
    asset.comments;
});

Customize:

client.assets.find({ id: 12345 }, function(errasset){
    asset.url // http://media.getchute.com/media/:id 
    asset.url.width(640) // http://media.getchute.com/media/:id/w/640 
    asset.url.height(480) // http://media.getchute.com/media/:id/h/480 
    asset.url.fill(640, 480) // http://media.getchute.com/media/:id/640x480 
    asset.url.fit(640, 480) // http://media.getchute.com/media/:id/fit/640x480 
});

Like:

client.assets.heart({ id: 12345 }, function(errasset){
    // +1 to asset with ID=12345 
});
 
client.assets.unheart({ id: 12345 }, function(errasset){
    // -1 to asset with ID=12345 
});

Remove:

client.assets.remove({ id: 12345 }, function(err){
    // asset with ID=12345 removed 
});

Bundles allow you to create dynamic sets of photos

Find:

// bundle with ID=12345 
client.bundles.find({ id: 12345 }, function(errbundle){
    bundle.id;
});

Create:

client.bundles.create({
    ids: [134234, 534125]
}, function(errbundle){
    // bundle with assets 134234 and 534125 created 
});

Remove:

client.bundles.remove({ id: 12345 }, function(err){
    // bundle with ID=12345 removed 
});

Chute provides a simple upload flow that provides image processing and more.

// info about files 
var files = [{ filename: 'image.jpg', size: 124235, md5: '0cc175b9c0f1b6a831c399e269772661' }];
// ID of chute which you want upload image to 
var chutes = [12423523];
 
client.uploads.upload({ files: files, chutes: chutes }, function(errassets){
    // assets is an array of asset IDs, which were just uploaded 
});

Tests

Put your app credentials(access token and id) into test and run it with: mocha --timeout 10000

License

© Chute Corporation.