seafile-docs

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.

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 "[email protected]&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": "[email protected]"
},
{
    "email": "[email protected]"
}
]

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": "[email protected]"
}

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/[email protected]/

Sample response

...
< HTTP/1.0 201 CREATED
< Location: https://cloud.seafile.com/api2/accounts/[email protected]/
...

"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

  • password
  • is_staff (defaults to False)
  • is_active (defaults to True)

Sample request

curl -v -X PUT -d "password=654321&is_staff=true" -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/accounts/[email protected]/

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

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/[email protected]/

Sample response

"success"

Errors

  • 403 Permission error, only administrator can perform this action

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 or p is missing, or p 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 or p is missing, or p is not valid file path(e.g. /foo/bar/).

User Messages

List User Messages

GET https://cloud.seafile.com/api2/user/msgs/{id_or_email}/

Request parameters

  • id_or_email

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/user/msgs/2/"

Sample response

{
    "to_email": "[email protected]",
    "next_page": -1,
    "msgs": [
        {
            "attachments": [
                {
                    "path": "/123.md",
                    "repo_id": "c7436518-5f46-4296-97db-2fcba4c8c8db"
                }
            ],
            "timestamp": 1398233096,
            "from_email": "[email protected]",
            "msgid": 3,
            "msg": "another test msg",
            "nickname": "user"
        },
        {
            "attachments": [],
            "timestamp": 1398233067,
            "from_email": "[email protected]",
            "msgid": 2,
            "msg": "a test msg",
            "nickname": "user"
        }
    ]
}

Errors

  • 404 user not found

Reply A User Message

POST https://cloud.seafile.com/api2/user/msgs/{id_or_email}/

Request parameters

  • id_or_email
  • message

Sample request

curl -d "message=this is a user msg reply" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/user/msgs/2/"

Sample response

{
    "msgid": 4
}

Errors

  • 404 user not found

Count Unseen Messages

GET https://cloud.seafile.com/api2/unseen_messages/

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/unseen_messages/"

Sample response

{
    "count": 1
}

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": "[email protected]",
            "msgnum": 0,
            "mtime": 1398231100,
            "id": 1,
            "name": "lian"
        },
        {
            "ctime": 1398236081042441,
            "creator": "[email protected]",
            "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.

Group Member

Add A Group Member

PUT https://cloud.seafile.com/api2/groups/{group_id}/members/

Request parameters

  • user_name

Sample request

curl -X PUT -d "[email protected]"-H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/groups/1/members/"

Sample response

{"success": true}

Errors

  • 400 invalid group id
  • 403 only administrators can add group members
  • 404 unable to find group

Delete A Group Member

DELETE https://cloud.seafile.com/api2/groups/{group_id}/members/

Request parameters

  • user_name

Sample request

curl -X DELETE -d "[email protected]" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/groups/1/members/"

Sample response

{"success": true}

Errors

  • 400 invalid group id
  • 403 only administrators can remove group members
  • 404 unable to find group

Group Message

Get Group Messages

GET https://cloud.seafile.com/api2/group/msgs/{group_id}/

Request parameters

  • group_id

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/group/msgs/1/"

Sample response

{
    "next_page": -1,
    "msgs": [
        {
            "reply_cnt": 0,
            "timestamp": 1398230602,
            "replies": [],
            "from_email": "[email protected]",
            "msgid": 1,
            "msg": "test discuss",
            "nickname": "user"
        }
    ]
}

Get Group Message Detail

GET https://cloud.seafile.com/api2/group/{group_id}/msg/{msg_id}/

Request parameters

  • group_id
  • msg_id

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/group/1/msg/1/"

Sample response

{
    "reply_cnt": 2,
    "timestamp": 1398230602,
    "replies": [
        {
            "msg": "this is another test",
            "timestamp": 1398232319,
            "nickname": "user",
            "msgid": 1,
            "from_email": "[email protected]"
        },
        {
            "msg": "this is another test",
            "timestamp": 1398232508,
            "nickname": "user",
            "msgid": 3,
            "from_email": "[email protected]"
        }
    ],
    "from_email": "[email protected]",
    "msgid": 1,
    "msg": "test discuss",
    "nickname": "user"
}

Errors

  • 404 message not found

Send A Group Message

POST https://cloud.seafile.com/api2/group/msgs/{group_id}/

Request parameters

  • message
  • group_id
  • repo_id(optional)
  • path(optional)

Sample request

curl -d "message=this is another test&repo_id=c7436518-5f46-4296-97db-2fcba4c8c8db&path=/123.md" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/group/msgs/1/"

Sample response

{
    "msgid": 3
}

Reply A Group Message

POST https://cloud.seafile.com/api2/group/{group_id}/msg/{msg_id}

Request parameters

  • group_id
  • msg_id
  • message

Sample request

curl -d "message=this is a reply" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/group/1/msg/1/"

Sample response

{
    "msgid": 3
}

Errors

  • 404 message not found

Get Group Message Replies

GET https://cloud.seafile.com/api2/new_replies/

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/new_replies/"

Sample response

[
    {
        "reply_cnt": 1,
        "timestamp": 1398231100,
        "replies": [
            {
                "msg": "@user test reply",
                "timestamp": 1398234493,
                "nickname": "123",
                "msgid": 5,
                "from_email": "[email protected]"
            }
        ],
        "from_email": "[email protected]",
        "att": {
            "repo": "c7436518-5f46-4296-97db-2fcba4c8c8db",
            "path": "/123.md",
            "type": "file",
            "src": "recommend"
        },
        "msgid": 3,
        "msg": "this is another test",
        "nickname": "user"
    }
]

Share

GET https://cloud.seafile.com/api2/shared-links/

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/shared-links/"

Sample response

{"fileshares": [{"username": "[email protected]", "repo_id": "a582d3bc-bcf5-421e-9125-741fa56d18d4", "ctime": null, "s_type": "d", "token": "e410827494", "view_cnt": 0, "path": "/123/"}, {"username": "[email protected]", "repo_id": "affc837f-7fdd-4e91-b88a-32caf99897f2", "ctime": null, "s_type": "f", "token": "0ae587a7d1", "view_cnt": 0, "path": "/lian123.md"}]}

PUT https://cloud.seafile.com/api2/repos/{repo-id}/file/shared-link/

Request parameters

  • repo-id
  • type
  • p (Path to the file)

Sample request

Create download link for file

curl -v  -X PUT -d "type=f&p=/foo.md" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/afc3b694-7d4c-4b8a-86a4-89c9f3261b12/file/shared-link/

Create download link for directory

curl -v  -X PUT -d "type=d&p=/123/" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/afc3b694-7d4c-4b8a-86a4-89c9f3261b12/file/shared-link/

Sample response

...
< HTTP/1.0 201 CREATED
< Location: https://cloud.seafile.com/f/9b437a7e55/
...

Success

Response code 201(Created) is returned and the Location header provides shared link.

Errors

  • 400 Path is missing
  • 500 Internal server error

DELETE https://cloud.seafile.com/api2/shared-links/?t=0ae587a7d1

Request parameters

  • t

Sample request

curl -v -X DELETE -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/shared-links/?t=0ae587a7d1"

Sample response

...
< HTTP/1.0 200 OK
...

Shared Libraries

List Shared Libraries

GET https://cloud.seafile.com/api2/shared-repos/

Sample request

curl -v -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/shared-repos/

Sample response

[{"repo_id": "7d42522b-1f6f-465d-b9c9-879f8eed7c6c", "share_type": "personal", "permission": "rw", "encrypted": false, "user": "[email protected]", "last_modified": 1361072500, "repo_desc": "ff", "group_id": 0, "repo_name": "\u6d4b\u8bd5\u4e2d\u6587pdf"}, {"repo_id": "79bb29cd-b683-4844-abaf-433952723ca5", "share_type": "group", "permission": "rw", "encrypted": false, "user": "[email protected]", "last_modified": 1359182468, "repo_desc": "test", "group_id": 1, "repo_name": "test_enc"}]

List Be Shared Libraries

GET https://cloud.seafile.com/api2/beshared-repos/

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/beshared-repos/"

Sample response

"[{"user": "[email protected]", "repo_id": "989e3952-9d6f-4427-ab16-4bf9b53212eb", "share_type": "personal", "permission": "rw", "encrypted": false, "repo_desc": "lib shared to imwhatiam", "enc_version": false, "last_modified": 1398218747, "is_virtual": false, "group_id": 0, "repo_name": "lib shared to imwhatiam"}]"

Share A Library

PUT https://cloud.seafile.com/api2/shared-repos/{repo-id}/

Request parameters

  • share_type ('personal', 'group' or 'public')
  • user (or users)
  • group_id
  • permission

If share_type is 'personal' then 'user' or 'users' param are required, if share_type is 'group' then 'group_id' parameter is required. If share_type is 'public' no other params is required.

'user' or 'users' parameters can be a comma separated list of emails, in this case the share will be done for more users at the same time. If a problem is encountered during multiple users sharing then the sharing process is aborted.

Sample request

curl -X PUT -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/shared-repos/7d42522b-1f6f-465d-b9c9-879f8eed7c6c/?share_type=group&[email protected]&group_id=1&permission=rw"

Sample response

"success"

Unshare A Library

DELETE https://cloud.seafile.com/api2/shared-repos/{repo-id}/

Request parameters

  • share_type ('personal', 'group' or 'public')
  • user
  • group_id

If share_type is 'personal' then 'user' param is required, if share_type is 'group' then 'group_id' parameter is required. If share_type is 'public' no other params is required.

Sample request

curl -X DELETE -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/shared-repos/7d42522b-1f6f-465d-b9c9-879f8eed7c6c/?share_type=personal&[email protected]&group_id=0"

Sample response

"success"

Shared Files

List Shared Files

GET https://cloud.seafile.com/api2/shared-files/

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/shared-files/"

Sample response

{"priv_share_in": [{"s_type": "f", "repo_id": "989e3952-9d6f-4427-ab16-4bf9b53212eb", "permission": "r", "to_user": "[email protected]", "token": "94aace406a", "from_user": "[email protected]", "path": "/lib.md"}], "priv_share_out": [{"s_type": "f", "repo_id": "affc837f-7fdd-4e91-b88a-32caf99897f2", "permission": "r", "to_user": "[email protected]", "token": "b7b31bc39b", "from_user": "[email protected]", "path": "/lian123.md"}]}

Download Shared File

GET https://cloud.seafile.com/api2/f/{token}/

Request parameters

  • token(file share token)

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/f/ad93cd0d66/"

Sample response

"http://192.168.1.101:8082/files/89223601/lib.md"

Errors

  • 404 repo/token/file not found
  • 520 OPERATION FAILED, fail to get file id by path

Get Shared File Detail

GET https://cloud.seafile.com/api2/f/{token}/detail/

Request parameters

  • token(file share token)

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/f/ad93cd0d66/detail/"

Sample response

{"repo_id": "989e3952-9d6f-4427-ab16-4bf9b53212eb", "name": "lib.md", "mtime": 1398218747, "path": "/lib.md", "type": "file", "id": "0000000000000000000000000000000000000000", "size": 0}

Errors

  • 404 repo/token/file not found
  • 520 OPERATION FAILED, fail to get file id by path

Delete Shared File

DELETE https://cloud.seafile.com/api2/shared-files/?t=0ae587a7d1

Request parameters

  • t

Sample request

curl -v -X DELETE -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/shared-files/?t=94aace406a"

Sample response

...
< HTTP/1.0 200 OK
...

Download Private Shared File

GET https://cloud.seafile.com/api2/s/f/{token}/

Request parameters

  • token(private file share token)

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/s/f/c5aa5f0219/"

Sample response

"http://192.168.1.101:8082/files/6960d5a4/lib.md"

Errors

  • 404 repo/token/file not found
  • 520 OPERATION FAILED, fail to get file id by path

Get Private Shared File Detail

GET https://cloud.seafile.com/api2/s/f/{token}/detail/

Request parameters

  • token(private file share token)

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/s/f/c5aa5f0219/detail/"

Sample response

{"repo_id": "989e3952-9d6f-4427-ab16-4bf9b53212eb", "name": "lib.md", "shared_by": "[email protected]", "mtime": 1398218747, "path": "/lib.md", "type": "file", "id": "0000000000000000000000000000000000000000", "size": 0}

Errors

  • 404 repo/token/file not found
  • 520 OPERATION FAILED, fail to get file id by path

Library

Library

Get Default Library

GET https://cloud.seafile.com/api2/default-repo/

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/default-repo/"

Sample response

{
    "repo_id": "691b3e24-d05e-43cd-a9f2-6f32bd6b800e",
    "exists": true
}

Create Default Library

POST https://cloud.seafile.com/api2/default-repo/

Sample request

curl -X POST -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/default-repo/"

Sample response

{
    "repo_id": "691b3e24-d05e-43cd-a9f2-6f32bd6b800e",
    "exists": true
}

List Libraries

GET https://cloud.seafile.com/api2/repos/

Sample request

curl -H 'Authorization: Token 24fd3c026886e3121b2ca630805ed425c272cb96' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/

Sample response

[
{
    "permission": "rw",
    "encrypted": false,
    "mtime": 1400054900,
    "owner": "[email protected]",
    "id": "f158d1dd-cc19-412c-b143-2ac83f352290",
    "size": 0,
    "name": "foo",
    "type": "repo",
    "virtual": false,
    "desc": "new library",
    "root": "0000000000000000000000000000000000000000"
},
{
    "permission": "rw",
    "encrypted": false,
    "mtime": 1400054802,
    "owner": "[email protected]",
    "id": "0536b11a-a5fd-4482-9314-728cb3472f54",
    "size": 0,
    "name": "foo",
    "type": "repo",
    "virtual": false,
    "desc": "new library",
    "root": "0000000000000000000000000000000000000000"
}
]

Get Library Info

GET https://cloud.seafile.com/api2/repos/{repo-id}/

Request parameters

  • repo-id

Sample request

curl -G -H 'Authorization: Token 24fd3c026886e3121b2ca630805ed425c272cb96' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/632ab8a8-ecf9-4435-93bf-f495d5bfe975/

Sample response

{
"encrypted": false,
"password_need": null,
"mtime": null,
"owner": "self",
"id": "632ab8a8-ecf9-4435-93bf-f495d5bfe975",
"size": 1356155,
"name": "org",
"root": "b5227040de360dd22c5717f9563628fe5510cbce",
"desc": "org file",
"type": "repo"
}

Get Library Owner

GET https://cloud.seafile.com/api2/repos/{repo-id}/owner/

Request parameters

  • repo-id

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d9b477fd' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/owner/

Sample response

{
"owner": "[email protected]"
}

Errors

  • 403 Permission error, only administrator can perform this action

Get Library History

GET https://cloud.seafile.com/api2/repos/{repo-id}/history/

Request parameters

  • repo-id

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d9b477fd' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/history/

Sample response

{"commits": [{"rev_file_size": 0, "rev_file_id": null, "ctime": 1398045167, "creator_name": "[email protected]", "creator": "0000000000000000000000000000000000000000", "root_id": "ca2625da6be6e211ddd584615ef3bfaa531e66aa", "rev_renamed_old_path": null, "parent_id": "205c469f0830df09b13024601524058757a43128", "new_merge": false, "repo_id": "691b3e24-d05e-43cd-a9f2-6f32bd6b800e", "desc": "Modified \"api.md\"", "id": "eb62721812e0c3122889b5facde971b353ad176b", "conflict": false, "second_parent_id": null}, {"rev_file_size": 0, "rev_file_id": null, "ctime": 1398045158, "creator_name": "[email protected]", "creator": "0000000000000000000000000000000000000000", "root_id": "0b7a31adf4ea8b29ad5a5920420b548da11dd32f", "rev_renamed_old_path": null, "parent_id": "2ba85ee6072efea51a3483843ea7de9b6d1d1eb2", "new_merge": false, "repo_id": "691b3e24-d05e-43cd-a9f2-6f32bd6b800e", "desc": "Added \"api.md\"", "id": "205c469f0830df09b13024601524058757a43128", "conflict": false, "second_parent_id": null}], "page_next": false}

Create Library

POST https://cloud.seafile.com/api2/repos/

Request parameters

  • name
  • desc (defaults to "new repo")
  • passwd (needed by encrypt library)

Sample request

curl -v -d "name=foo&desc=new library" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/

Sample response

{
"encrypted": "",
"enc_version": 0,
"repo_id": "f15811fd-5c19-412c-b143-2ac83f352290",
"magic": "",
"relay_id": "c5e41170db250ea497075e2911104faf0105b7fb",
"repo_version": 1,
"relay_addr": "cloud.seafile.com",
"token": "c1f3defe9ba408cd7964427ec276843e9d10c23b",
"relay_port": "10001",
"random_key": "",
"email": "[email protected]",
"repo_name": "foo"
}

Success

Response code 200 and newly created library information are returned.

Errors

  • 400 Library name missing.
  • 520 Operation failed.

Check/Create Sub Library

check if a dir has a corresponding sub_repo, if it does not have, create one

GET https://cloud.seafile.com/api2/repos/{repo-id}/dir/sub_repo/?p=/\&name=sub_lib

Request parameters

  • repo-id
  • p
  • name

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d9b477fd' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/dir/sub_repo/?p=/\&name=sub_lib

Sample response

{"sub_repo_id": "c0a3283c-013c-4a7c-8f68-006f06fa6dec"}

Errors

  • 400 Argument missing
  • 500 INTERNAL SERVER ERROR

Delete Library

DELETE https://cloud.seafile.com/api2/repos/{repo-id}/

Sample request

curl -v -X DELETE -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/8f5f2222-72a8-454f-ac40-8397c5a556a8/

Sample response

"success"

Errors

  • 400 Library does not exist.

  • 403 Only library owner can perform this operation.

Decrypt Library

POST https://cloud.seafile.com/api2/repos/{repo-id}/

Request parameters

  • password

Sample request

curl -v -d "password=123" -H 'Authorization: Token e6a33d61954f219a96b60f635cf02717964e4385' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/0c2465a5-4753-4660-8a22-65abec9ec8d0/

Sample response

"success"

Errors

  • 400 Incorrect password
  • 409 Repo is not encrypt
  • 500 Internal server error

Create Public Library

POST https://cloud.seafile.com/api2/repos/{repo-id}/public/

Request parameters

  • repo-id

Sample request

curl -X POST -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d9b477fd' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/public/

Sample response

...
< HTTP/1.0 200 OK
...

Success

Response code is 200(OK), and a string "success" is returned.

Errors

  • 404 Repo not found
  • 403 Forbid to access this repo
  • 500 INTERNAL SERVER ERROR, Unable to make repo public

Remove Public Library

DELETE https://cloud.seafile.com/api2/repos/{repo-id}/public/

Request parameters

  • repo-id

Sample request

curl -X DELETE -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d9b477fd' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/public/

Sample response

...
< HTTP/1.0 200 OK
...

Success

Response code is 200(OK), and a string "success" is returned.

Errors

  • 404 Repo not found
  • 403 Forbid to access this repo
  • 500 INTERNAL SERVER ERROR, Unable to remove public repo

Fetch library download info

GET https://cloud.seafile.com/api2/repos/{repo-id}/download-info/

Request parameters

  • repo-id

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d9b477fd' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/download-info/

Sample response

{
"applet_root": "https://localhost:13420",
"relay_addr": "localhost",
"token": "46acc4d9ca3d6a5c7102ef379f82ecc1edc629e1",
"repo_id": "dae8cecc-2359-4d33-aa42-01b7846c4b32",
"relay_port": "10002",
"encrypted": "",
"repo_name": "test",
"relay_id": "8e4b13b49ca79f35732d9f44a0804940d985627c",
"email": "[email protected]"
}

List Virtual Libraries

GET https://cloud.seafile.com/api2/virtual-repos/

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/virtual-repos/"

Sample response

{"virtual-repos":
    [
        {"virtual_perm": "rw", "store_id": null, "worktree_invalid": false, "encrypted": false, "origin_repo_name": "lian", "last_modify": 0, "no_local_history": false, "head_branch": null, "last_sync_time": 0, "id": "51344de8-456f-4dc7-ac08-718827994252", "size": 0, "share_permission": null, "worktree_changed": false, "worktree_checktime": 0, "origin_path": "/lian", "is_virtual": true, "origin_repo_id": "a582d3bc-bcf5-421e-9125-741fa56d18d4", "version": 1, "random_key": null, "is_original_owner": true, "shared_email": null, "enc_version": 0, "head_cmmt_id": "bc666fdc60d2352b9f6a0324ac64168d43724eed", "desc": null, "index_corrupted": false, "magic": null, "name": "lian", "worktree": null, "auto_sync": false, "relay_id": null},
        {"virtual_perm": "rw", "store_id": null, "worktree_invalid": false, "encrypted": false, "origin_repo_name": "lian", "last_modify": 0, "no_local_history": false, "head_branch": null, "last_sync_time": 0, "id": "c0a3283c-013c-4a7c-8f68-006f06fa6dec", "size": 0, "share_permission": null, "worktree_changed": false, "worktree_checktime": 0, "origin_path": "/", "is_virtual": true, "origin_repo_id": "a582d3bc-bcf5-421e-9125-741fa56d18d4", "version": 1, "random_key": null, "is_original_owner": true, "shared_email": null, "enc_version": 0, "head_cmmt_id": "ff18229aadc9acc73ad481278d5b4c42b3353aa0", "desc": null, "index_corrupted": false, "magic": null, "name": "123", "worktree": null, "auto_sync": false, "relay_id": null}
    ]
}

Search Libraries

GET https://cloud.seafile.com/api2/search/

Request parameters

  • q
  • per_page (optional)

Sample request

curl -G -H 'Authorization: Token 24fd3c026886e3121b2ca630805ed425c272cb96' -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/search/?q=keyword

Sample response

{
    "has_more": false,
    "total": 3,
    "results": [
        {
            "repo_id": "691b3e24-d05e-43cd-a9f2-6f32bd6b800e",
            "name": "api.md",
            "oid": "8ea78453bb474359cd9d8e2c4c4d8d9cbdcef0a2",
            "last_modified": 1398045167,
            "fullpath": "/api.md",
            "size": 18939
        },
        {
            "repo_id": "c5509062-9bca-4933-a7e0-c6da1d5f82be",
            "name": "home.md",
            "oid": "dda57aaffa5179829e064c7d0c142f47a8a65d3b",
            "last_modified": 1397096831,
            "fullpath": "/home.md",
            "size": 1954
        },
        {
            "repo_id": "c5509062-9bca-4933-a7e0-c6da1d5f82be",
            "name": "\u5e38\u89c1\u5b89\u88c5\u95ee\u9898.md",
            "oid": "8573f982eeb478b932a55ec13218f4f90a7c5a27",
            "last_modified": 1397188959,
            "fullpath": "/\u5e38\u89c1\u5b89\u88c5\u95ee\u9898.md",
            "size": 1050
        }
    ]
}

Errors

  • 404 Search not supported.
  • 400 Missing argument q.

File

Download File

GET https://cloud.seafile.com/api2/repos/{repo-id}/file/?p=/foo

Request parameters

  • repo-id
  • p

Sample request

curl  -v  -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/file/?p=/foo.c

Sample response

"https://cloud.seafile.com:8082/files/adee6094/foo.c"

Errors

  • 400 Path is missing
  • 404 File not found
  • 520 Operation failed.

Get File Detail

GET https://cloud.seafile.com/api2/repos/{repo-id}/file/detail/?p=/foo.c

  • repo-id
  • p

Sample request

curl -H 'Authorization: Token f2210dacd3606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/file/detail/?p=/foo.c

Sample response

{
"id": "013d3d38fed38b3e8e26b21bb3463eab6831194f",
"mtime": 1398148877,
"type": "file",
"name": "foo.py",
"size": 22
}

Errors

  • 400 Path is missing
  • 520 Operation failed.

Get File History

GET https://cloud.seafile.com/api2/repos/{repo-id}/file/history/?p=/foo.c

Request parameters

  • repo-id
  • p

Sample request

curl -H 'Authorization: Token f2210dacd3606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/file/history/?p=/foo.c

Sample response

{
"commits":
    [
        {
        "rev_file_size": 0,
        "repo_id": "a582d3bc-bcf5-421e-9125-741fa56d18d4",
        "ctime": 1398149763,
        "creator_name": "[email protected]",
        "creator": "0000000000000000000000000000000000000000",
        "root_id": "b64d413d9894c9206beac3faf9c2a0d75b4a8ebf",
        "rev_renamed_old_path": null,
        "parent_id": "8e546762e1657ab22dad83e9cb1e5ea31a767c9a",
        "new_merge": false,
        "version": 1,
        "conflict": false,
        "desc": "Added \"foo.c\"",
        "id": "9464f7499bfa7363d563282361339eaf96a93318",
        "rev_file_id": "0000000000000000000000000000000000000000",
        "second_parent_id": null
        },
        {
        "rev_file_size": 0,
        "repo_id": "a582d3bc-bcf5-421e-9125-741fa56d18d4",
        "ctime": 1398146059,
        "creator_name": "[email protected]",
        "creator": "0000000000000000000000000000000000000000",
        "root_id": "572413414257c76039897e00aeb35f819471206b",
        "rev_renamed_old_path": null,
        "parent_id": "f977bdb0ebb205645c3b42216c2817e511c3f68f",
        "new_merge": false,
        "version": 1,
        "conflict": false,
        "desc": "Added \"foo.c\"",
        "id": "a1ec20709675f4dc8db825cdbca296be245d189b",
        "rev_file_id": "0000000000000000000000000000000000000000",
        "second_parent_id": null
        }
    ]
}

Errors

  • 400 Path is missing
  • 404 File not found

Download File From a Revision

GET https://cloud.seafile.com/api2/repos/{repo-id}/file/revision/?p=/foo.c&commit_id=a1ec20709675f4dc8db825cdbca296be245d189b

Request parameters

  • repo-id
  • p
  • commit_id

Sample request

curl -H 'Authorization: Token f2210dacd3606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/file/revision/?p=/foo.c\&commit_id=a1ec20709675f4dc8db825cdbca296be245d189b

Sample response

"https://cloud.seafile.com:8082/files/adee6094/foo.c"

Errors

  • 400 Path is missing
  • 404 Revision not found

Create File

POST https://cloud.seafile.com/api2/repos/{repo-id}/file/?p=/foo.c

Request parameters

  • repo-id
  • p
  • operation

Sample request

curl -v -d "operation=create" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/file/?p=/foo.c

Sample response

...
< HTTP/1.1 201 CREATED
...
"success"

Success

Response code is 201, and a string "success" is returned.

Errors

  • 403 FORBIDDEN, You do not have permission to move file
  • 520 OPERATION FAILED, fail to create file

Rename File

POST https://cloud.seafile.com/api2/repos/{repo-id}/file/?p=/foo.c

Request parameters

  • repo-id
  • p
  • operation
  • newname

Sample request

curl -v -d "operation=rename&newname=newfoo.c" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/file/?p=/foo.c

Sample response

...
< HTTP/1.1 301 MOVED PERMANENTLY
...
"success"

Success

Response code is 301, and a string "success" is returned.

Errors

  • 400 BAD REQUEST, Path is missing or invalid(e.g. p=/) or newname is missing(newname too long)
  • 403 FORBIDDEN, You do not have permission to rename file
  • 404 NOT FOUND, repo not found
  • 409 CONFLICT, the newname is the same to the old
  • 520 OPERATION FAILED, fail to rename file

Move File

POST https://cloud.seafile.com/api2/repos/{repo-id}/file/?p=/foo.c

Request parameters

  • repo-id
  • p
  • operation
  • dst_repo
  • dst_dir

Sample request

curl -v -d "operation=move&dst_repo=affc837f-7fdd-4e91-b88a-32caf99897f2&dst_dir=/" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/file/?p=/foo.c

Sample response

...
< HTTP/1.1 301 MOVED PERMANENTLY
...
"success"

Success

Response code is 301, and a string "success" is returned.

Errors

  • 400 BAD REQUEST, Path is missing or invalid(e.g. p=/)
  • 403 FORBIDDEN, You do not have permission to move file
  • 404 NOT FOUND, repo not found
  • 500 INTERNAL SERVER ERROR

Copy File

POST https://cloud.seafile.com/api2/repos/{repo_id}/fileops/copy/

Request parameters

  • p: source folder path, defaults to "/"
  • file_names: list of file/folder names to copy. Multiple file/folder names can be seperated by :.
  • dst_repo: the destination repo id
  • dst_dir: the destination folder in dst_repo

Sample request

curl -d "dst_repo=73ddb2b8-dda8-471b-b7a7-ca742b07483c&dst_dir=/&file_names=foo.c" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/repos/c7436518-5f46-4296-97db-2fcba4c8c8db/fileops/copy/

Sample response

"success"

Errors

  • 400 missing argument
  • 403 You do not have permission to copy file
  • 404 repo not found
  • 502 failed to copy file

Revert File

PUT https://cloud.seafile.com/api2/repos/{repo_id}/file/revert/

Request parameters

  • repo_id
  • p
  • commit_id

Sample request

curl -v -X PUT -d "commit_id=a1ec20709675f4dc8db825cdbca296be245d189b&p=/foo.c" -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/8f5f2222-72a8-454f-ac40-8397c5a556a8/file/revert/

Sample response

...
< HTTP/1.0 200 OK
...

{"ret": 0}

Success

Response code 200(OK) is returned.

Errors

  • 400 Path is missing

Delete File

DELETE https://cloud.seafile.com/api2/repos/{repo-id}/file/?p=/foo

Request parameters

  • repo-id
  • p

Sample request

curl -X DELETE -v  -H 'Authorization: Token f2210dacd3606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/file/?p=/foo.c

Sample response

...
< HTTP/1.0 200 OK
...
"success"

Errors

  • 400 Path is missing
  • 520 Operation failed.

Note

This can also be used to delete directory.

Upload File

GET https://cloud.seafile.com/api2/repos/{repo-id}/upload-link/

Request parameters

  • repo-id

Sample request

curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" https://cloud.seafile.com/api2/repos/99b758e6-91ab-4265-b705-925367374cf0/upload-link/

Sample response

"http://cloud.seafile.com:8082/upload-api/ef881b22"

Errors

500 Run out of quota
Upload File

After getting the upload link, POST to this link for uploading files.

POST http://cloud.seafile.com:8082/upload-api/ef881b22

Errors

400 Bad request
440 Invalid filename
441 File already exists
500 Internal server error

Sample request

curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" -F [email protected] -F filename=test.txt -F parent_dir=/ http://cloud.seafile.com:8082/upload-api/ef881b22

Sample response

"adc83b19e793491b1c6ea0fd8b46cd9f32e592fc"

Note

For python client uploading, see https://cloud.seafile.com/f/1b0ade6edc/

Update file

GET https://cloud.seafile.com/api2/repos/{repo-id}/update-link/

Request parameters

  • repo-id

Sample request

curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" https://cloud.seafile.com/api2/repos/99b758e6-91ab-4265-b705-925367374cf0/update-link/

Sample response

"http://cloud.seafile.com:8082/update-api/ef881b22"

Errors

500 Run out of quota
Update File

After getting the upload link, POST to this link for uploading files.

POST http://cloud.seafile.com:8082/update-api/ef881b22

Request parameters

  • target_file

Sample request

curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" -F [email protected] -F filename=test.txt -F target_file=/test.txt http://cloud.seafile.com:8082/upload-api/ef881b22

Returns

The id of the updated file

Sample response

"adc83b19e793491b1c6ea0fd8b46cd9f32e592fc"

Errors

  • 400 Bad request
  • 440 Invalid filename
  • 500 Internal server error

GET https://cloud.seafile.com/api2/repos/{repo-id}/upload-blks-link/

Request parameters

  • repo-id

Sample request

curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" https://cloud.seafile.com/api2/repos/99b758e6-91ab-4265-b705-925367374cf0/upload-blks-link/

Sample response

"https://cloud.seafile.com/seafhttp/upload-blks-api/c1e6823d"

Errors

  • 403 Can not access repo
  • 520 above quota

GET https://cloud.seafile.com/api2/repos/{repo-id}/update-blks-link/

Request parameters

  • repo-id

Sample request

curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" https://cloud.seafile.com/api2/repos/99b758e6-91ab-4265-b705-925367374cf0/update-blks-link/

Sample response

"https://cloud.seafile.com/seafhttp/update-blks-api/c1e6823d"

Errors

  • 403 Can not access repo
  • 520 above quota

Directory

List Directory Entries

GET https://cloud.seafile.com/api2/repos/{repo-id}/dir/

  • repo-id
  • p (optional): The path to a directory. If p is missing, then defaults to '/' which is the top directory.
  • oid (optional)

Sample request

curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d9b477fd" -H 'Accept: application/json; indent=4' https://cloud.seafile.com/api2/repos/99b758e6-91ab-4265-b705-925367374cf0/dir/?p=/foo

Sample response

If oid is the latest oid of the directory, returns "uptodate" , else returns

[
{
    "id": "0000000000000000000000000000000000000000",
    "type": "file",
    "name": "test1.c",
    "size": 0
},
{
    "id": "e4fe14c8cda2206bb9606907cf4fca6b30221cf9",
    "type": "dir",
    "name": "test_dir"
}
]

Errors

  • 404 The path is not exist.
  • 440 Repo is encrypted, and password is not provided.
  • 520 Operation failed..

Create New Directory

POST https://cloud.seafile.com/api2/repos/{repo-id}/dir/

  • repo-id
  • p
  • operation=mkdir (post)

Sample request

curl -d  "operation=mkdir" -v  -H 'Authorization: Tokacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/dir/?p=/foo

Sample response

...
< HTTP/1.0 201 CREATED
< Location: https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/dir/?p=/foo
...

"success"

Success

Response code 201(Created) is returned, and Location header provides the url of created directory.

Errors

  • 400 Path is missing or invalid(e.g. p=/)
  • 520 Operation failed.

Notes

Newly created directory will be renamed if the name is duplicated.

Rename Directory

POST https://cloud.seafile.com/api2/repos/{repo-id}/dir/

Parameters

  • p (path)
  • operation=rename (post)
  • newname (the new name for directory)

Sample request

curl -d  "operation=rename&newname=pinkfloyd_newfolder" -v  -H 'Authorization: Tokacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/dir/?p=/foo

Success

Response code 200 if everything is ok

Errors

  • 403 if You do not have permission to rename a folder
  • 400 if newname is not given
  • 520 if Failed to rename directory (generic problem)

Notes

If the new name is the same of the old name no operation will be done.

Delete Directory

DELETE https://cloud.seafile.com/api2/repos/{repo-id}/dir/

  • repo-id
  • p

Sample request

curl -X DELETE -v  -H 'Authorization: Token f2210dacd3606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/dir/?p=/foo

Sample response

...
< HTTP/1.0 200 OK
...
"success"

Success

Response code is 200(OK), and a string "success" is returned.

Errors

  • 400 Path is missing or invalid(e.g. p=/)
  • 520 Operation failed.

Note

This can also be used to delete file.

Download Directory

GET https://cloud.seafile.com/api2/repos/{repo-id}/dir/download/?p=/foo

  • repo-id
  • p

Sample request

curl -H 'Authorization: Token f2210dacd3606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/dir/?p=/foo

Sample response

"https://cloud.seafile.com:8082/files/adee6094/foo"

Errors

  • 400 Path is missing or invalid(e.g. p=/), or unable to download directory, size is too large
  • 404 Repo(path) not found(exist)
  • 520 Operation failed.

Share Directory

POST https://cloud.seafile.com/api2/repos/{repo-id}/dir/share/

  • repo-id
  • emails
  • s_type
  • path
  • perm

Sample request

curl -v -X POST -d "[email protected]&s_type=d&path=/dir&perm=r" -H 'Authorization: Token f2210dacd3606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/dir/share/

Sample response

...
< HTTP/1.0 200 OK
...

Success

Response code is 200(OK).

Batch Delete

Pipelining over HTTP/1.1 can be used to delete multiple files and directories without losing performance.

A sample request looks like curl -X DELETE https://cloud.seafile.com/api2/repos/{repo-id}/dir/?p=/foo http://cloud.seafile.com/api2/repos/{repo-id}/dir/?p=/bar. This code snippet shows how to use Python client to batch delete multiple files and directories. See http://cloud.seafile.com/f/f7fd5d5b9d/

Get Avatar

Get User Avatar

GET https://cloud.seafile.com/api2/avatars/user/{user}/resized/{size}/

Request parameters

  • user
  • size

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/avatars/user/[email protected]/resized/80/

Sample response

{
    "url": "http://127.0.0.1:8000/media/avatars/default.png",
    "is_default": true,
    "mtime": 0
}

Get Group Avatar

GET https://cloud.seafile.com/api2/avatars/group/{group_id}/resized/{size}/

Request parameters

  • group_id
  • size

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/avatars/group/1/resized/80/

Sample response

{
    "url": "http://127.0.0.1:8000/media/avatars/groups/default.png",
    "is_default": true,
    "mtime": 0
}

List Group And Contacts

GET https://cloud.seafile.com/api2/groupandcontacts/

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/groupandcontacts/"

Sample response

{
    "contacts": [
        {
            "msgnum": 0,
            "mtime": 0,
            "lastmsg": null,
            "email": "[email protected]",
            "name": "123"
        }
    ],
    "umsgnum": 0,
    "replynum": 0,
    "groups": [
        {
            "ctime": 1398134171327948,
            "creator": "[email protected]",
            "msgnum": 0,
            "mtime": 0,
            "lastmsg": null,
            "id": 1,
            "name": "lian"
        }
    ],
    "gmsgnum": 0,
    "newreplies": []
}

Get File Activities

GET https://cloud.seafile.com/api2/events/

Sample request

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/events/"

Sample response

 {"more_offset": 16, "events":[{"repo_id": "6f3d28a4-73ae-4d01-a727-26774379dcb9", "author": "[email protected]", "nick": "lins05", "time": 1398078909, "etype": "repo-update", "repo_name": "Downloads", "desc": "Added \"seafile-cli_3.0.2_i386.tar.gz\"."},{"repo_id": "6f3d28a4-73ae-4d01-a727-26774379dcb9", "author": "[email protected]", "nick": "lins05", "time": 1398075540, "etype": "repo-update", "repo_name": "Downloads", "desc": "Added \"seafile-server_3.0.0_x86-64.tar.gz\"."}], "more": false}