Skip to content
@deckyard/seafile

seafile cheatsheet

Every export of @deckyard/seafile. Guides are listed in the introduction.

jennifer
import "@deckyard/seafile/" as seafile;

Every function that sends a request throws Error{kind: "seafile"} when it fails. A repoId is a library id (a UUID) from libraries; a path is absolute in its library (/docs/a.txt, / for the root). Times are seconds since the epoch. "Account" marks a verb a library API token client (withRepoToken) refuses before sending anything.

Constants

ConstantValueMeaning
ERROR_KIND"seafile"the kind of every error the deck throws
DOWNLOAD_LIMIT67108864the largest file get accepts with maxBytes 0 (64 MiB)
REPLY_LIMIT67108864the largest reply body of every other request with Client.replyLimit 0 (64 MiB)
MAX_RETRIES10the most retries withRetries accepts
MAX_PAGES1000pages trashAll and fileHistory follow before they refuse
CHUNK_SIZE8388608the chunk size of putResumable with chunkSize 0 (8 MiB)
LIBRARY_TYPES["mine", "shared", "group", "org"]the type filters of libraries
SHARE_PERMISSIONS["r", "rw", "admin", "preview", "cloud-edit", "invisible"]the permissions of share and changeShare besides custom-<id>; the last three need Professional
TOKEN_PERMISSIONS["r", "rw"]the permissions of a library API token

Types

A literal of a deck struct names every field, so build ShareLinkOptions and SearchOptions from the zero value: def o as seafile.ShareLinkOptions; then set fields.

Client

FieldMeaning
url as stringhttp[s]://host[:port][/path], without /api2
token as stringthe account or library API token; "" for none
legacyAuth as boolsend Token <t> instead of Bearer <t>
repoToken as booltoken is a library API token
repoId as stringthe token's library; "" for unchecked
fileServer as stringa further origin transfer links may use, scheme://host:port; "" for none
tls as http.TlsOptionscertificate checking
timeoutMs as intidle timeout per request; 0 for 30 s, never negative
retries as intretries of a GET answered 429 or 5xx, 0 to MAX_RETRIES
replyLimit as intthe largest reply body of every request but get; 0 for REPLY_LIMIT, negative for none
plainHttp as boolsend credentials and transfer tokens over http:// to a host that is not loopback

Build a Client with client and the with* functions, not a literal.

ServerInfo

FieldMeaning
version as stringe.g. 13.0.29
encryptedLibraryVersion as intthe version new encrypted libraries get
features as list of stringe.g. seafile-basic, seafile-pro

Account

FieldMeaning
email as stringthe user id: an e-mail address or x@auth.local
name as stringthe display name
loginId as stringthe login id; often ""
contactEmail as stringthe contact address
institution as stringthe institution
department as stringthe department
isStaff as boolwhether the account is a system admin
usage as intbytes used
total as intthe quota in bytes; -2 for unlimited

Library

FieldMeaning
id as stringthe library id
name as stringthe name
type as stringrepo, srepo (shared with the account), grepo (group); "" when not reported
owner as stringthe owner's user id
size as intbytes
mtime as intthe last change
encrypted as boolwhether it is encrypted
permission as stringr or rw

Entry

FieldMeaning
name as stringthe name
path as stringthe path in its library
type as stringfile or dir
id as stringthe object id; all zeros for an empty file or folder
size as intbytes; 0 for a folder
mtime as intthe modification time
permission as stringr or rw; "" when not reported
starred as boolwhether the account starred it
isLocked as boolwhether the file is locked
modifier as stringthe last modifier's user id; "" when not reported

Revision

FieldMeaning
commitId as stringthe commit; revertFile takes it
fileId as stringthe file object id of this version
path as stringthe path the file had
size as intbytes
ctime as intwhen it was committed
creator as stringthe user id that made it
creatorName as stringthat user's display name
description as stringthe commit message

Progress

FieldMeaning
done as intitems finished
total as intitems in the task
canceled as boolwhether it was canceled
failed as boolwhether it failed
successful as boolwhether it completed

Share

From sharedWithMe, userName, groupId, groupName and isAdmin are zero.

FieldMeaning
kind as stringuser or group; public from sharedWithMe
user as stringthe user id (from sharedWithMe: the sharer); "" for a group
userName as stringthe user's display name
groupId as intthe group id; 0 for a user
groupName as stringthe group's name
permission as stringone of SHARE_PERMISSIONS or custom-<id>; from shares, admin reads as rw with isAdmin
isAdmin as boolwhether the share grants admin rights
repoId as stringthe library
repoName as stringthe library's name; "" when not reported
path as stringthe shared folder, / for the whole library

Starred

FieldMeaning
repoId as stringthe library
repoName as stringthe library's name
path as stringthe path, / for the library
name as stringthe name
isDir as boola folder or library
mtime as intthe modification time
deleted as boolwhether it no longer exists

ShareLinkOptions

FieldMeaning
password as stringthe password visitors give; "" for none
expireDays as intdays until expiry; 0 for never
noDownload as boolview only
canEdit as boolvisitors may edit (office files)
canUpload as boolvisitors may upload into a shared folder
FieldMeaning
token as stringthe link token
link as stringthe URL to hand out
repoId as stringthe library
repoName as stringthe library's name
path as stringwhat it shares
name as stringthe name of what it shares
isDir as boolwhether it shares a folder
viewCount as inthow often it was opened
ctime as intwhen it was made
expires as intwhen it expires; 0 for never
isExpired as boolwhether it has expired
canEdit as boolvisitors may edit
canDownload as boolvisitors may download
canUpload as boolvisitors may upload
FieldMeaning
token as stringthe link token
link as stringthe URL to hand out
repoId as stringthe library
repoName as stringthe library's name
path as stringthe folder
viewCount as inthow often it was opened
ctime as intwhen it was made
expires as intwhen it expires; 0 for never
isExpired as boolwhether it has expired

TrashItem

FieldMeaning
name as stringthe name
parentDir as stringthe folder it was deleted from
path as stringits full path
isDir as boolwhether it is a folder
size as intbytes; 0 for a folder
deleted as intwhen it was deleted
commitId as stringthe commit that still holds it
objId as stringthe object id; "" for a folder

TrashPage

FieldMeaning
items as list of TrashItemthe items, newest first
more as boolwhether the server has more to scan
scanStat as stringthe cursor of the next page; "" on the last

ApiToken

FieldMeaning
repoId as stringthe library it opens
appName as stringits name
generatedBy as stringthe user id that made it
permission as stringr or rw
token as stringthe token, for withRepoToken

SearchOptions

FieldMeaning
repoId as stringonly this library; "" for all
path as stringonly below this folder; needs repoId
page as intthe page, from 1; 0 for the first
perPage as intresults per page; 0 for the server's default

SearchHit

FieldMeaning
repoId as stringthe library
repoName as stringthe library's name
name as stringthe name
path as stringthe path in the library
isDir as boolwhether it is a folder
size as intbytes
mtime as intthe modification time

Connecting

FunctionReturnsDoes
seafile.client(baseUrl)Clienta client without credentials; refuses a URL with a query, fragment or user, a scheme other than http/https, no host or a bad port
seafile.login(c, username, password, otp)stringan account token for withToken; otp the 2FA code or ""
seafile.withToken(c, token)Clientauthenticate with an account token
seafile.withRepoToken(c, repoId, token)Clientauthenticate with a library API token (via-repo-token endpoints)
seafile.withLegacyAuth(c)Clientsend Token <t> (servers before 11.0)
seafile.withFileServer(c, url)Clientaccept transfer links on that origin too
seafile.withPlainHttp(c)Clientallow credentials and transfer links over http:// off loopback
seafile.withCaCert(c, pem)Clienttrust a PEM certificate (bytes); undoes withInsecure
seafile.withInsecure(c)Clientaccept any certificate
seafile.withTimeout(c, ms)Clientset the idle timeout; refuses a negative ms
seafile.withRetries(c, n)Clientretry API GETs answered 429 or 5xx, n 0 to MAX_RETRIES
seafile.withReplyLimit(c, maxBytes)Clientcap every reply body but get's; 0 for REPLY_LIMIT, negative for none
seafile.call(c, method, path, body)json.Valueany endpoint under /api2/ or /api/v2.1/; method GET/POST/PUT/PATCH/DELETE; body JSON text (sent as application/json)
seafile.serverInfo(c)ServerInfoversion and features; no credentials needed
seafile.account(c)Accountaccount; the user the token belongs to, with usage and quota

Libraries

FunctionReturnsDoes
seafile.libraries(c, type)list of Libraryaccount; one of LIBRARY_TYPES or "" for all
seafile.library(c, id)Libraryaccount; one library
seafile.tokenLibrary(c)Librarylibrary API token only: its library's id and name
seafile.createLibrary(c, name, password)Libraryaccount; password "" for plain, else encrypted (sent to the server)
seafile.renameLibrary(c, id, name)-account
seafile.removeLibrary(c, id)-account; delete with everything in it
seafile.decrypt(c, id, password)-account; unlock an encrypted library on the server (sends the password)

Files and folders

FunctionReturnsDoes
seafile.listDir(c, repoId, path, type, recursive)list of Entryentries of a folder; type file, dir or ""; recursive for every depth
seafile.fileDetail(c, repoId, path)Entryone file
seafile.dirDetail(c, repoId, path)Entryaccount; one folder
seafile.exists(c, repoId, path)boolfalse on 404 File/Folder ... not found; a missing library throws
seafile.mkdir(c, repoId, path, parents)stringmake a folder; a taken name gets x (1), the path made is returned; parents makes missing ones and keeps an existing folder
seafile.get(c, repoId, path, maxBytes)bytesdownload via the download link; 0 for DOWNLOAD_LIMIT, negative for none
seafile.put(c, repoId, path, data, replace)Entryupload via the upload link; without replace a taken name gets x (1).txt; account: drops a chunked upload's temp file at the path first (best effort; aborts another client's chunked upload of it); a name with " goes as one chunk, one with \ throws
seafile.update(c, repoId, path, data)stringaccount; overwrite an existing file, returns the new file id; drops a temp file as put
seafile.putResumable(c, repoId, path, data, chunkSize, replace, resume)Entryupload in chunks; chunkSize 0 for CHUNK_SIZE; resume continues at the server's offset (account token, same data only); otherwise starts at 0; account: drops a stale temp file, then chunks from 0, and restarts once after a first-chunk 400; library token: a first-chunk 400 sends the whole data through put in one POST
seafile.rename(c, repoId, path, name)stringrename in place; returns the new path (a taken name gets x (1))
seafile.copy(c, repoId, path, toRepoId, toDir)-copy a file or folder into a folder
seafile.move(c, repoId, path, toRepoId, toDir)-move a file or folder into a folder
seafile.copyItems(c, repoId, dir, names, toRepoId, toDir)-copy items of one folder, synchronously
seafile.moveItems(c, repoId, dir, names, toRepoId, toDir)-move items of one folder, synchronously
seafile.copyAsync(c, repoId, dir, names, toRepoId, toDir)stringaccount; start a background copy, returns the task id
seafile.moveAsync(c, repoId, dir, names, toRepoId, toDir)stringaccount; start a background move
seafile.taskProgress(c, taskId)Progressaccount; state of a background copy or move
seafile.cancelTask(c, taskId)-account; cancel it
seafile.remove(c, repoId, path)-move a file or folder to the trash; not /
seafile.removeItems(c, repoId, dir, names)-delete items of one folder; missing names are skipped
seafile.lockFile(c, repoId, path)-lock a file (Professional edition)
seafile.unlockFile(c, repoId, path)-unlock it (Professional edition)

History

FunctionReturnsDoes
seafile.fileHistory(c, repoId, path)list of Revisionaccount; versions of a file, newest first, past renames; refuses past MAX_PAGES
seafile.revertFile(c, repoId, path, commitId)-restore a file to a commit's version
seafile.revertDir(c, repoId, path, commitId)-restore a folder to a commit's state

Shares and stars

FunctionReturnsDoes
seafile.shares(c, repoId, path, kind)list of Shareaccount; users (kind user) or groups (group) a library (/) or folder is shared with
seafile.share(c, repoId, path, kind, who, permission)-account; share with a user id or group id; a reported failure throws
seafile.changeShare(c, repoId, path, kind, who, permission)-account; change a share's permission
seafile.unshare(c, repoId, path, kind, who)-account; end a share
seafile.sharedFolders(c)list of Shareaccount; folders the account shares
seafile.sharedWithMe(c)list of Shareaccount; libraries shared with the account; sharer and permission for user shares only
seafile.starred(c)list of Starredaccount; starred items
seafile.star(c, repoId, path)-account; star a library (/), folder or file
seafile.unstar(c, repoId, path)-account; unstar it
FunctionReturnsDoes
seafile.createShareLink(c, repoId, path, opts)ShareLinka download link; a library API token takes no password or expiry
seafile.shareLinks(c)list of ShareLinkaccount; every share link
seafile.shareLinksOf(c, repoId, path)list of ShareLinkaccount; links of a library (path "") or of one path
seafile.deleteShareLink(c, token)-account; delete a share link
seafile.createUploadLink(c, repoId, path, password, expireDays)UploadLinkaccount; others upload into a folder through it
seafile.uploadLinks(c)list of UploadLinkaccount; every upload link
seafile.deleteUploadLink(c, token)-account; delete an upload link

Trash

FunctionReturnsDoes
seafile.trash(c, repoId, path, scanStat)TrashPageaccount; one page below a folder; scanStat "" for the first
seafile.trashAll(c, repoId, path)list of TrashItemaccount; every page; stops at a repeated cursor, refuses past MAX_PAGES
seafile.restore(c, repoId, items)-account; put items back, one request per commit
seafile.cleanTrash(c, repoId, keepDays)-account; drop history older than keepDays; no undo

Library API tokens

FunctionReturnsDoes
seafile.createApiToken(c, repoId, appName, permission)ApiTokenaccount; a token for one library, r or rw
seafile.apiTokens(c, repoId)list of ApiTokenaccount; the library's tokens
seafile.setApiTokenPermission(c, repoId, appName, permission)ApiTokenaccount; change a token's permission
seafile.deleteApiToken(c, repoId, appName)-account; revoke a token
FunctionReturnsDoes
seafile.search(c, query, opts)list of SearchHitaccount; full-text search (Professional edition; Community Edition answers 403)
seafile.searchNames(c, repoId, query)list of Entryaccount; files and folders of one library whose name contains query; folders dir