seafile-api
v0.3.0
Published
npm module for Seafile Web API
Downloads
11
Readme
seafile-api
seafile-api
is a small npm module for accessing the Seafile Web API and thus controlling a Seafile instance from within a Node.js application.
Though there are quite many API methods, at the moment this module just implements a small subset of the available functions.
Documentation
Installation
$ npm install seafile-api
Initialization
You will need a valid access token to make API requests. See the API docs for further information on how to obtain a token: Web API | Quick Start. At the moment, this module does not support obtainment of access tokens.
var SeafileAPI = require('seafile-api');
var sf = new SeafileAPI('https://cloud.seafile.com', 'accesstoken123456789');
Usage
See the official API docs for detailed information about the methods and used parameters. Default values are used if optional parameters are not set.
listAccounts(params, callback)
sf.listAccounts({
start: 0,
limit: 100,
scope: 'DB'
}, function(err, accounts, httpcode){
if(err) console.error('Error:', err);
console.log(accounts);
});
- All parameters are optional
getAccountInfo(email, callback)
sf.getAccountInfo('[email protected]', function(err, body, httpcode){
console.log(body);
});
createAccount(params, callback)
sf.createAccount({
email: '[email protected]',
password: 'foobar123',
is_staff: 0,
is_active: 1
}, function(err, data, httpcode){
console.log(data);
});
email
: requiredpassword
: requiredis_staff
: optionalis_active
: optional
updateAccount(params, callback)
sf.updateAccount({
email: '[email protected]',
name: 'John Doe',
is_staff: 0,
is_active: 1
}, function(err, body, httpcode){
console.log(body);
});
email
: required- all other params are optional
deleteAccount(email, callback)
sf.deleteAccount('[email protected]', function(err, body, httpcode){
console.log(body);
});
addGroupMember(options, callback)
sf.addGroupMember({
user_name: '[email protected]',
group_id: 1
}, function(err, body){
console.log(body);
});
user_name
: requiredgroup_id
: required
deleteGroupMember(options, callback)
sf.deleteGroupMember({
user_name: '[email protected]',
group_id: 1
}, function(err, body){
console.log(body);
});
user_name
: requiredgroup_id
: required
moveMultiple(options, callback)
sf.moveMultiple({
src_repo: 'source_repo_id',
dst_repo: 'dest_repo_id',
file_names: [
'file.txt',
'image.jpg'
],
dst_path: '/',
p: '/'
}, function(err, body){
console.log(body);
});
src_repo
: requireddst_repo
: requiredfile_name
: required- all other params are optional
renameDirectory(options, callback)
sf.renameDirectory({
repo_id: 'repo_id',
p: 'foo',
newname: 'pinkfloyd_newfolder'
}, function(err, body){
console.log(body);
});
repo_id
: requiredp
: requirednewname
: required
createDirectory(options, callback)
sf.createDirectory({
repo_id: 'repo_id',
p: 'bar',
}, function(err, body){
console.log(body);
});
repo_id
: requiredp
: required
listDirEntries(options, callback)
sf.listDirEntries({
repo_id: 'repo_id',
p: '/',
t: 'd',
recursive: 1
}, function(err, body){
console.log(body);
});
repo_id
: required- all other params are optional