lakenen / node-box-view

A node client for the Box View API
MIT License
13 stars 2 forks source link

Build Status

Box View API Node Client

A node client for the Box View API

Installation

npm install box-view

Usage

Create a client:

var myKey = process.env.BOX_VIEW_API_TOKEN;
var client = require('box-view').createClient(myKey);

See the Box View API Documentation for a list of available endpoints and their parameters.

Documents

list

client.documents.list(options, callback)

Fetch a list of documents uploaded using this API key.

Example:

client.documents.list(function (err, list, res) {
    // `list` is the JSON-parsed response body
    // `res` is the HTTP Response object
    console.log(list);
});

get

client.documents.get(id, options, callback)

Fetch the metadata for a single document.

Example:

client.documents.get('some document id', function (err, doc, res) {
    // `doc` is the JSON-parsed response body
    // `res` is the HTTP Response object
    console.log(doc);
});

update

client.documents.update(id, data, options, callback)

Update the metadata for a single document.

delete (documents)

client.documents.delete(id, options, callback)

Delete a single document.

uploadFile

client.documents.uploadFile(file, options, callback)

Do a multipart upload.

NOTE: the retry option is not supported for multipart uploads (uploads specified via string filename or Stream.

uploadURL

client.documents.uploadURL(url, options, callback)

Do a URL upload of a file.

getContent

client.documents.getContent(id, options, callback)

Fetch a document of a specified format.

Example:

client.documents.getContent(id, { extension: 'zip' }, function (err, res) {
    if (err) {
        console.error(err);
        return;
    }

    // `res` is the HTTP Response object
    res.pipe(fs.createWriteStream('./doc.zip'));
});

getThumbnail

client.documents.getThumbnail(id, width, height, options, callback)

Fetch a thumbnail for the given document id.

Example:

client.documents.getThumbnail(id, params, function (err, res) {
    if (err) {
        console.error(err);
        return;
    }

    // `res` is the HTTP Response object
    res.pipe(fs.createWriteStream('./thumbnail.png'));
});

Sessions

create

client.sessions.create(id, options, callback)

Request a viewing session for a document.

delete (sessions)

client.sessions.delete(id, options, callback)

Delete a single session.

Running Tests

Make sure you have the development dependencies installed by running npm install, then you should be able to run the tests with npm test.

API Support

For any bugs or feedback with conversion or the API in general, please email api@box.com.

License

(The MIT License)

Copyright 2014 Cameron Lakenen