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(params, callback)
Fetch a list of documents uploaded using this API key.
params
- (Object
) a map of URL parametersparams.limit
- (int
) The number of documents to return (default: 10, max: 50)params.created_before
- (Date
) An upper limit on the creation timestamps of documents returned (default: now)params.created_after
- (Date
) A lower limit on the creation timestamps of documents returnedcallback
- (function(error, response)
) A callback to call with the response data (or error)
get
client.documents.get(id, fields, callback)
Fetch the metadata for a single document.
id
- (String
) The document uuidfields
- (String
) Comma-separated list of fields to return (e.g., 'id,type,name,status'
); id and type are always returnedcallback
- (function(error, response)
) A callback to call with the response data (or error)
update
client.documents.update(id, data, callback)
Update the metadata for a single document
id
- (String
) The document uuiddata
- (Object
) The new metadata (currently only name
is supported)callback
- (function(error, response)
) A callback to call with the response data (or error)
delete
client.documents.delete(id, callback)
Delete a single document
id
- (String
) The document uuidcallback
- (function(error, response)
) A callback to call with the response data (or error)
uploadFile
client.documents.uploadFile(file, params, callback)
Do a multipart upload from a file path or readable stream
file
- (String
or stream.Readable
) A path to a file to read or a readable streamparams
- (Object
) Upload parametersparams.name
- (String
) The name of the fileparams.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 768params.non_svg
- (Boolean
) Whether to also create the non-svg version of the documentcallback
- (function(error, response)
) A callback to call with the response data (or error)
uploadURL
client.documents.uploadFile(url, params, callback)
Do a URL upload of a file
url
- (String
) A URL to a publicly-accessible file to uploadparams
- (Object
) Upload parametersparams.name
- (String
) The name of the fileparams.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 768params.non_svg
- (Boolean
) Whether to also create the non-svg version of the documentcallback
- (function(error, response)
) A callback to call with the response data (or error)
getContent
client.documents.getContent(id, extension, callback)
Fetches a document in the form specified by extension
, which can be pdf
or zip
.
- If an extension is not specified, the document’s original format is returned.
id
- (string
) The document uuidextension
- (string
) The document format to requestcallback
- (function(error, response)
) A callback to call with the response (or error)
getThumbnail
client.documents.getThumbnail(id, params, callback)
Fetches a thumbnail for the given document id
id
- (string
) The document uuidparams
- (Object
) The thumbnail paramsparams.width
- (int
) The thumbnail widthparams.height
- (int
) The thumbnail heightcallback
- (function(error, response)
) A callback to call with the response (or error)
Sessions
create
Request a viewing session for a documentRequest a viewing session for a document
id
- (String
) The document uuidparams
- (Object
) Session parametersparams.duration
- (int
) The duration in minutes until the session expires (default: 60)params.expires_at
- (Date
) The timestamp at which the session should expireparams.is_downloadable
- (boolean
) Whether a the original file will be available for download via GET /sessions/{id}/content while the session is activecallback
- (function(error, response)
) A callback to call with the response data (or error)
Copyright and License
Copyright 2014 Box, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.