Reference for the PCloudAPI class, grouped by what each method does.
Every method returns a typed promise. A result of 0 means success; any other value comes with an error string. The client does not throw on a non-zero result, so check it. It throws only when pCloud returns something that is not JSON, and the message has access_token, auth, password and client_secret values redacted.
import { PCloudAPI } from "@kud/pcloud"const api = new PCloudAPI()api.setAuth("example-session-token")const folder = await api.listFolder("/Documents")if (folder.result !== 0) throw new Error(folder.error)
Multipart upload of a Uint8Array or ArrayBuffer. nopartial is on by default so a failed transfer cannot leave a truncated file; pass noPartial: false to disable it
getZipLink(fileids, folderids?, filename?)
A download link for a zip of several items
Downloads and zip links need a session token, not an OAuth access token.
listShares() returns { shares: { outgoing, incoming }, requests: { outgoing, incoming } }, not a flat array.
The ids are easy to confuse because both are plain numbers. Accepted shares carry a shareid and report permissions as four booleans. Pending requests carry a sharerequestid and the permissions bitmask. removeShare takes the former; acceptShare and declineShare take the latter. Sending the wrong one makes pCloud reply Please provide 'shareid'. and nothing happens.
Deleted items. They are lifted from metadata.contents to contents, matching the other listings
restoreFromTrash(fileid, { restoreTo? })
Restore a file
restoreFolderFromTrash(folderid, { restoreTo? })
Restore a folder
Pass restoreTo (a folder id) whenever the original parent may have been deleted too, which is the usual case after a folder deletion. Otherwise pCloud chooses the destination itself.
All response and metadata types are exported from the package root and prefixed PCloud, for example PCloudFile, PCloudFolderResponse, PCloudUserInfo, PCloudRevision, PCloudPublink, PCloudTrashItem, PCloudDiffEntry and the generic PCloudResponse<T>.