Seafile Web API
Posted sunansheng
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Seafile Web API相关的知识,希望对你有一定的参考价值。
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 查找seafile内部文件链接