Seafile Web API V2
API Basics
All API calls must be authenticated with a valid Seafile API key.
curl -H 'Authorization: Token 24fd3c026886e3121b2ca630805ed425c272cb96' https://cloud.seafile.com/api2/auth/ping/
The api key can be retrieved by the obtain auth api. See the Quick Start for details.
For each API, we provide curl
examples to illustrate the usage. We also provide python
and javascript
examples, please refer to https://github.com/haiwen/webapi-examples for details.
Status Code
- 200: OK
- 201: CREATED
- 202: ACCEPTED
- 301: MOVED_PERMANENTLY
- 400: BAD_REQUEST
- 403: FORBIDDEN
- 404: NOT_FOUND
- 409: CONFLICT
- 429: TOO_MANY_REQUESTS
- 440: REPO_PASSWD_REQUIRED
- 441: REPO_PASSWD_MAGIC_REQUIRED
- 500: INTERNAL_SERVER_ERROR
- 520: OPERATION_FAILED
Quick Start
ping
curl https://cloud.seafile.com/api2/ping/
"pong"
obtain auth token
curl -d "username=username@example.com&password=123456" https://cloud.seafile.com/api2/auth-token/
{"token": "24fd3c026886e3121b2ca630805ed425c272cb96"}
auth ping
curl -H 'Authorization: Token 24fd3c026886e3121b2ca630805ed425c272cb96' https://cloud.seafile.com/api2/auth/ping/
"pong"
Account
List Accounts
GET https://cloud.seafile.com/api2/accounts/
Request parameters
- start (default to 0)
- limit (default to 100)
- scope (default None, accepted values: 'LDAP' or 'DB')
To retrieve all users, just set both start
and limit
to -1
.
If scope parameter is passed then accounts will be searched inside the specific scope, otherwise it will be used the old approach: first LDAP and, if no account is found, DB.
Sample request
curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/accounts/
Sample response
[
{
"email": "foo@foo.com"
},
{
"email": "bar@bar.com"
}
]
Errors
- 403 Permission error, only administrator can perform this action
Get Account Info
GET https://cloud.seafile.com/api2/accounts/{email}/
Request parameters
Sample request
curl -v -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/accounts/user@mail.com/
Sample response
{
"is_staff": false,
"is_active": true,
"id": 2,
"create_time": 1356061187741686,
"usage": 651463187,
"total": 107374182400,
"email": "user@mail.com"
}
Errors
- 403 Permission error, only administrator can perform this action
Check Account Info
GET https://cloud.seafile.com/api2/account/info/
Sample request
curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/account/info/
Sample response
{
"usage": 26038531,
"total": 104857600,
"email": "user@example.com"
}
Errors
- 403 Invalid token
Create Account
PUT https://cloud.seafile.com/api2/accounts/{email}/
Request parameters
- password
- is_staff (defaults to False)
- is_active (defaults to True)
Sample request
curl -v -X PUT -d "password=123456" -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/accounts/newaccount@gmail.com/
Sample response
...
< HTTP/1.0 201 CREATED
< Location: https://cloud.seafile.com/api2/accounts/newaccount@gmail.com/
...
"success"
Success
Response code 201(Created) is returned and the Location header provides shared link.
Errors
- 403 Permission error, only administrator can perform this action
Update Account
PUT https://cloud.seafile.com/api2/accounts/{email}/
Request parameters
At least one of followings:
- password
- is_staff
- is_active
- name
- note
- storage
Sample request
curl -v -X PUT -d "password=654321&is_staff=true&storage=1073741824" -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/accounts/user@mail.com/
Sample response
...
< HTTP/1.0 200 OK
...
"success"
Success
Response code 200(OK) is returned.
Errors
- 400 Bad Request, keyword password is required
- 403 Permission error, only administrator can perform this action
Migrate Account
POST https://cloud.seafile.com/api2/accounts/{email}/
Request parameters
- op
- to_user this user must exist
Sample request
curl -v -d "op=migrate&to_user=user2@mail.com" -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/accounts/user@mail.com/
Sample response
...
< HTTP/1.0 200 OK
...
"success"
Success
Response code 200(OK) is returned.
Errors
- 400 Bad Request, arguments are missing or invalid
- 403 Permission error, only administrator can perform this action
Delete Account
DELETE https://cloud.seafile.com/api2/accounts/{email}/
Sample request
curl -v -X DELETE -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/accounts/newaccount@gmail.com/
Sample response
"success"
Errors
- 403 Permission error, only administrator can perform this action
Get Server Information
GET https://cloud.seafile.com/api2/server-info
Note:
- No authentication required.
- Added in seafile community edition server
4.0.5
or pro edition server4.0.3
Sample request
curl https://cloud.seafile.com/api2/server-info/
Sample response
Sample response from a seafile community edition server:
{
"version": "4.0.6",
"features": [
"seafile-basic",
]
}
Sample response from a seafile pro edition server:
{
"version": "4.0.6",
"features": [
"seafile-basic",
"seafile-pro",
"office-preview",
"file-search"
]
}
Starred Files
List starred files
GET https://cloud.seafile.com/api2/starredfiles/
Sample request
curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e6199b477fd" -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/starredfiles/
Sample response
[
{
"repo": "99b758e6-91ab-4265-b705-925367374cf0",
"mtime": 1355198150,
"org": -1,
"path": "/foo/bar.doc",
"dir": false,
"size": 0
},
{
"repo": "99b758e6-91ab-4265-b705-925367374cf0",
"mtime": 1353751237,
"org": -1,
"path": "/add_folder-blue.png",
"dir": false,
"size": 3170
}
]
Star A File
POST https://cloud.seafile.com/api2/starredfiles/
Request parameters
- repo_id (post)
- p (post)
Sample request
curl -v -d "repo_id=dae8cecc-2359-4d33-aa42-01b7846c4b32&p=/foo.md" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/starredfiles/
Sample response
...
< HTTP/1.0 201 CREATED
< Location: https://cloud.seafile.com/api2/starredfiles/
...
"success"
Success
Response code is 201(Created) and Location header provides url of starred file list.
Errors
- 400
repo_id
orp
is missing, orp
is not valid file path(e.g. /foo/bar/).
Unstar A File
DELETE https://cloud.seafile.com/api2/starredfiles/
Request parameters
- repo_id
- p
Sample request
curl -X DELETE -v -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' 'https://cloud.seafile.com/api2/starredfiles/?repo_id=dae8cecc-2359-4d33-aa42-01b7846c4b32&p=/foo.md'
Sample response
...
< HTTP/1.0 200 OK
...
"success"
Success
Response code is 200(OK), and a string named "success" is returned.
Errors
- 400
repo_id
orp
is missing, orp
is not valid file path(e.g. /foo/bar/).
Group
List Groups
GET https://cloud.seafile.com/api2/groups/
Sample request
curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/groups/"
Sample response
{
"replynum": 0,
"groups": [
{
"ctime": 1398134171327948,
"creator": "user@example.com",
"msgnum": 0,
"mtime": 1398231100,
"id": 1,
"name": "lian"
},
{
"ctime": 1398236081042441,
"creator": "user@example.com",
"msgnum": 0,
"mtime": 0,
"id": 2,
"name": "123"
}
]
}
Add A Group
PUT https://cloud.seafile.com/api2/groups/
Request parameters
- group_name
Sample request
curl -X PUT -d "group_name=newgroup" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/groups/"
Sample response
{"group_id": 3, "success": true}
Errors
- 400 There is already a group with that name.
Delete Group
DELETE https://cloud.seafile.com/api2/groups/{group_id}/
Request parameters
None
Sample request
curl -X DELETE -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/groups/1/"
Success
200 if everything is fine.
Errors
- 400 if ad group id format
- 404 if Group not found
- 403 if Forbid to delete group
- 520 if Failed to remove group (generic error)
Rename Group
POST https://cloud.seafile.com/api2/groups/{group_id}/
Request parameters
- operation (value must be 'rename')
- newname (the new name for the group)
Sample request
curl -d "operation=rename&newname=pinkfloyd_lovers" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/groups/1/"
Success
200 if everything is fine.
Errors
- 404 if Group not found
- 403 if Forbid to rename group
- 400 if Newname is missing or if Group name is not valid of if There is already a group with that name or Operation can only be rename.