Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

box-view

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

box-view

A node client for the Box View API

  • 0.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
42
decreased by-8.7%
Maintainers
1
Weekly downloads
 
Created
Source

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.

  • [options] - (object) An optional set of options for the request
    • [options.params] - (object) An optional map of URL parameters for filtering documents
    • [options.params.limit] - (int) The number of documents to return (default: 10, max: 50)
    • [options.params.created_before] - (Date) An upper limit on the creation timestamps of documents returned (default: now)
    • [options.params.created_after] - (Date) A lower limit on the creation timestamps of documents returned
    • [options.retry] - (boolean) Whether to retry the request after retry-after seconds if the retry-after header is sent (default: false)
  • [callback] - (Function) A callback to call with the following arguments:
    • an error object or null
    • JSON-parsed response data
    • the http response object

Example:

client.documents.list(function (err, body, res) {
    console.log(body)
});
get

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

Fetch the metadata for a single document.

  • id - (string) The document uuid
  • [options] - (object) An optional set of options for the request
    • [options.fields] - (Array or string) An optional array or comma-separated list of fields to return (e.g., ['name', 'status'] or 'name,status'); id and type are always returned
    • [options.retry] - (boolean) Whether to retry the request after retry-after seconds if the retry-after header is sent (default: false)
  • [callback] - (Function) A callback to call with the following arguments:
    • an error object or null
    • JSON-parsed response data
    • the http response object

Example:

client.documents.get('some document id', function (err, doc, res) {
    console.log(doc)
});
update

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

Update the metadata for a single document.

  • id - (string) The document uuid
  • data - (object) The new metadata (currently only name is supported)
  • [options] - (object) An optional set of options for the request
    • [options.retry] - (boolean) Whether to retry the request after retry-after seconds if the retry-after header is sent (default: false)
  • [callback] - (Function) A callback to call with the following arguments:
    • an error object or null
    • JSON-parsed response data
    • the http response object
delete

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

Delete a single document.

  • id - (string) The document uuid
  • [options] - (object) An optional set of options for the request
    • [options.retry] - (boolean) Whether to retry the request after retry-after seconds if the retry-after header is sent (default: false)
  • [callback] - (Function) A callback to call with the following arguments:
    • an error object or null
    • the http response object
uploadFile

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

Do a multipart upload.

  • file - (string or stream.Readable or File or Buffer) A path to a file to read, a readable stream, a File object (e.g., in a browser), or a Buffer
  • [options] - (object) An optional set of options for the request
    • [options.params] - (object) An optional map of upload parameters
    • [options.params.name] - (string) The name of the file. If options.params.name is not set, it will be inferred from the file path.
    • [options.params.thumbnails] - (string) Comma-separated list of thumbnail dimensions of the format {width}x{height} (e.g. '128×128,256×256') – width can be between 16 and 1024, height between 16 and 768
    • [options.params.non_svg] - (boolean) Whether to also create the non-svg version of the document
    • [options.retry] - (boolean) Whether to retry the request after retry-after seconds if the retry-after header is sent (default: false)
  • [callback] - (Function) A callback to call with the following arguments:
    • an error object or null
    • JSON-parsed response data
    • the http response object
uploadURL

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

Do a URL upload of a file.

  • [url] - (string) A URL to a publicly-accessible file to upload
  • [options] - (object) An optional set of options for the request
    • [options.params] - (object) An optional map of upload parameters
    • [options.params.name] - (string) The name of the file. If options.params.name is not set, it will be inferred from the URL.
    • [options.params.thumbnails] - (string) Comma-separated list of thumbnail dimensions of the format {width}x{height} (e.g. '128×128,256×256') – width can be between 16 and 1024, height between 16 and 768
    • [options.params.non_svg] - (boolean) Whether to also create the non-svg version of the document
    • [options.retry] - (boolean) Whether to retry the request after retry-after seconds if the retry-after header is sent (default: false)
  • [callback] - (Function) A callback to call with the following arguments:
    • an error object or null
    • JSON-parsed response data
    • the http response object
getContent

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

Fetch a document of a specified format.

  • If an extension is not specified, the document's original format is returned.
  • id - (string) The document uuid
  • [options] - (object) An optional set of options for the request
    • [options.extension] - (string) Optional document format to request ('pdf' or 'zip'). If excluded, the original document format will be returned.
    • [options.retry] - (boolean) Whether to retry the request after retry-after seconds if the retry-after header is sent (default: false)
  • [callback] - (Function) A callback to call with the following arguments:
    • an error object or null
    • the http response object

Example:

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

    res.pipe(fs.createWriteStream('./doc.zip'));
});
getThumbnail

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

Fetch a thumbnail for the given document id.

  • id - (string) The document uuid
  • width - (int) The thumbnail width
  • height - (int) The thumbnail height
  • [options] - (object) An optional set of options for the request
    • [options.retry] - (boolean) Whether to retry the request after retry-after seconds if the retry-after header is sent (default: false)
  • [callback] - (Function) A callback to call with the following arguments:
    • an error object or null
    • the http response object

Example:

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

    res.pipe(fs.createWriteStream('./thumbnail.png'));
});

Sessions

create

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

Request a viewing session for a document.

  • [id] - (string) The document uuid
  • [options] - (object) An optional set of options for the request
    • [options.params] - (object) An optional map of session parameters
    • [options.params.duration] - (int) The duration in minutes until the session expires (default: 60)
    • [options.params.expires_at] - (Date) The timestamp at which the session should expire
    • [options.params.is_downloadable] - (boolean) Whether the original file will be available for download via GET /sessions/{id}/content while the session is active
    • [options.retry] - (boolean) Whether to retry the request after retry-after seconds if the retry-after header is sent (default: false)
  • [callback] - (Function) A callback to call with the following arguments:
    • an error object or null
    • JSON-parsed response data
    • the http response object

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.

License

(The MIT License)

Copyright 2014 Cameron Lakenen

Keywords

FAQs

Package last updated on 05 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc