Giter VIP home page Giter VIP logo

chute-node's Introduction

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

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

Find:

// all chutes found
client.chutes.all(function(err, chutes){
	for(var i = 0; i < chutes.length; i++) {
		chute.id;
	}
});

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

// chute with ID=12345 found with contributors list inside
client.chutes.find({ id: 12345, contributors: true }, function(err, chute){
	chute.contributors;
});

// chute with ID=12345 found with members list inside
client.chutes.find({ id: 12345, members: true }, function(err, chute){
	chute.members;
});

// chute with ID=12345 found with parcels list inside
client.chutes.find({ id: 12345, parcels: true }, function(err, chute){
	chute.parcels;
});

// chute with ID=12345 found with everything inside
client.chutes.find({
	id: 12345,
	contributors: true,
	members: true,
	parcels: true
}, function(err, chute){
	chute.id;
});

Create:

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

Update:

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

Remove:

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

Assets

Assets represent photos and videos contained within a Chute.

Find:

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

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

Customize:

client.assets.find({ id: 12345 }, function(err, asset){
	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(err, asset){
	// +1 to asset with ID=12345
});

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

Remove:

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

Bundles

Bundles allow you to create dynamic sets of photos

Find:

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

Create:

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

Remove:

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

Uploads

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(err, assets){
	// 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.

chute-node's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.