Rclone — API Surface#

API types#

  • CLI (primary user-facing interface, ~60+ commands via cobra)
  • REST/HTTP JSON-RPC (remote control daemon: rclone rcd, rclone rc)
  • C Library (librclone — shared/static, same JSON-RPC protocol)
  • Protocol servers (rclone as backend: WebDAV, SFTP, FTP, HTTP, NFS, S3, DLNA, restic, Docker volume)
  • Backend plugin API (internal Go interface — fs.Fs — for storage backends)

CLI#

Framework#

Cobra (github.com/spf13/cobra) with pflag. All commands self-register via init() into a global root command in cmd/cmd.go. cmd/all/all.go blank-imports every command package.

Command structure#

File operations

CommandDescription
copy source:path dest:pathCopy src to dst, skipping identical files
sync source:path dest:pathSync src to dst (make dst identical)
move source:path dest:pathMove src to dst
copyto source:path dest:pathCopy single file/dir with rename
moveto source:path dest:pathMove single file/dir with rename
delete remote:pathRemove files in path
deletefile remote:pathRemove single file
purge remote:pathRemove directory and all contents
dedupe [mode] remote:pathDeduplicate files
bisync source: dest:Two-way sync
copyurl https://... dest:pathCopy a URL to remote
rcat remote:pathCopies stdin to remote
touch remote:pathCreate or update file timestamps
convmv dest:path --name-transformConvert filename encoding

Listing / inspection

CommandDescription
ls remote:pathList with size and path
lsd remote:pathList directories only
lsl remote:pathList with modification time
lsf remote:pathFormatted listing (configurable)
lsjson remote:pathList as JSON
tree remote:pathncurses-style directory tree
ncdu remote:pathInteractive disk usage browser
size remote:pathCount and total size
about remote:Show quota/usage for remote
cat remote:pathCat files to stdout
hashsum remote:pathCompute hashes
md5sum / sha1sum remote:pathSpecific hash commands

Verification

CommandDescription
check source: dest:Check src and dst match
checksum hash file remote:Check against hashsum file
cryptcheck remote: cryptedremote:Check crypt backend

Filesystem ops

CommandDescription
mkdir remote:pathCreate directory
rmdir remote:pathRemove empty directory
rmdirs remote:pathRemove all empty dirs
cleanup remote:Remove trashed files
settier tier remote:pathSet storage class/tier
link remote:pathCreate a public link

Mount (FUSE)

CommandDescription
mount remote:path /mntFUSE mount (via cgofuse)
cmount remote:path /mntAlternative FUSE via cmount
nfsmount remote:path /mntNFS mount (macOS-focused)

Serve (rclone as a server)

CommandDescription
serve http remote:pathHTTP file server
serve webdav remote:pathWebDAV server
serve ftp remote:pathFTP server
serve sftp remote:pathSFTP server
serve dlna remote:pathDLNA/UPnP media server
serve nfs remote:pathNFS server
serve s3 remote:pathS3-compatible server
serve restic remote:pathRestic REST repository
serve dockerDocker volume plugin daemon

Remote control

CommandDescription
rcd [flags]Start remote control daemon
rc method [params...]Send a call to running rcd
backend <command> remote:pathBackend-specific commands

Config management

CommandDescription
config editInteractive config editor
config show [remote]Show config
config create name type [k v...]Create new remote
config update name [k v...]Update remote
config delete nameDelete remote
config password name [k v...]Set password field
config reconnect remote:Re-auth a remote
config disconnect remote:Revoke auth
config encryption set/remove/checkConfig file encryption
config dump / providers / pathsInspect config

Utility

CommandDescription
versionShow version
selfupdateUpdate rclone binary
obscure passwordObfuscate a password string
reveal passwordReveal an obfuscated password
cryptdecode cryptedremote: pathShow original path inside crypt
authorize backendOAuth2 authorization flow
gitannexgit-annex special remote protocol
archive create/list/extractArchive operations
genautocomplete shellShell completion scripts
gendocs output_dirGenerate Markdown documentation

Flag patterns#

Global flags (apply to every command) are defined in fs/config/configflags/configflags.go and bound to fs.ConfigInfo:

  • --config — path to rclone.conf
  • --quiet / -q — suppress output
  • --verbose / -v — increase verbosity
  • --transfers N — parallel file transfers (default 4)
  • --checkers N — parallel checkers (default 8)
  • --retries N — retry count on failure
  • --bwlimit SPEC — bandwidth throttle (e.g. 10M:off)
  • --stats DURATION — stats reporting interval
  • --filter / --include / --exclude — filter rules
  • --dry-run / -n — simulate without modifying
  • --delete-before / --delete-during / --delete-after — sync deletion timing
  • --checksum / -c — compare by hash not modtime+size
  • --progress / -P — show real-time transfer progress
  • --dump-headers / --dump-bodies — HTTP debugging
  • --bind — outgoing interface binding
  • --disable FEATURE,... — disable specific backend features
  • --dscp — DSCP value for QoS

Backend-specific flags are declared as fs.Option slices in each backend’s RegInfo and appear as --backendname-optionname flags automatically via configflags.


Remote Control JSON-RPC API (rclone rcd / rclone rc)#

Transport and format#

  • HTTP server; default address localhost:5572
  • Requests: POST /operations/list (preferred) or GET /operations/list?param=val
  • Body: JSON object of parameters
  • Response: JSON object or {"error": "...","status": N}
  • Auth: optional basic auth (--rc-user / --rc-pass) or bearer token (--rc-token)
  • --rc-no-auth disables authentication (dangerous)

Router: chi (github.com/go-chi/chi/v5). Routes are GET|HEAD|POST|OPTIONS /* all dispatched to a single handler that looks up the path in rc.Calls registry.

Endpoint catalog#

All endpoints are self-registered by packages calling rc.Add(rc.Call{Path: "...", Fn: fn}) in their init() functions. They are grouped by namespace:

operations/ — file and filesystem operations

EndpointDescription
operations/listList a directory (fs, remote, options)
operations/statStat a single file/dir
operations/aboutQuota/usage info for remote
operations/copyfileCopy single file (srcFs, srcRemote → dstFs, dstRemote)
operations/movefileMove single file
operations/mkdirCreate directory
operations/rmdirRemove empty directory
operations/purgeRemove directory and contents
operations/rmdirsRemove empty directories recursively
operations/deleteDelete files in path
operations/deletefileDelete a single file
operations/copyurlDownload URL to remote
operations/uploadfileUpload via multipart form (HTTP only)
operations/cleanupDelete trashed files
operations/settierSet storage tier on directory
operations/settierfileSet storage tier on file
operations/sizeCompute total size of path
operations/publiclinkGenerate public sharing link
operations/fsinfoMetadata about a remote (backend type, features)
operations/checkVerify src and dst match
operations/hashsumCompute hashes for a directory
operations/hashsumfileCompute hashes from a hash file

sync/ — synchronization operations

EndpointDescription
sync/syncSync src to dst
sync/copyCopy src to dst
sync/moveMove src to dst
sync/bisyncTwo-way sync

core/ — runtime control

EndpointDescription
core/bwlimitGet or set bandwidth limit dynamically
core/statsGet transfer statistics
core/stats-resetReset statistics
core/stats-deleteDelete a stats group
core/transferredList completed transfers
core/group-listList stats groups
core/gcForce garbage collection
core/memstatsMemory usage statistics
core/pidGet process ID
core/versionGet rclone version
core/obscureObfuscate a string
core/commandRun any rclone CLI command
core/duDisk usage for a path
core/quitTerminate the rcd process

config/ — configuration management

EndpointDescription
config/listremotesList all configured remotes
config/getGet a remote’s config values
config/setUpdate config values
config/createCreate new remote
config/updateUpdate existing remote
config/deleteDelete a remote
config/dumpDump entire config
config/providersList available backend types
config/pathsShow config file paths
config/setpathSet config file path
config/passwordSet password on a remote
config/unlockUnlock encrypted config

fscache/ — Fs instance cache

EndpointDescription
fscache/entriesList cached Fs instances
fscache/clearFlush Fs cache

job/ — async job management

EndpointDescription
job/statusGet status of a background job
job/listList all jobs
job/stopStop a specific job
job/stopgroupStop all jobs in a group
job/batchExecute multiple rc calls in one request

mount/ — FUSE mount management (when available)

EndpointDescription
mount/mountMount a remote
mount/unmountUnmount a path
mount/unmountallUnmount all mounts
mount/listmountsList active mounts
mount/typesList available mount types

serve/ — protocol server management

EndpointDescription
serve/startStart a protocol server
serve/stopStop a specific server
serve/stopallStop all servers
serve/listList running servers
serve/typesList available protocols

vfs/ — VFS cache management (for mounted/served remotes)

EndpointDescription
vfs/refreshRefresh directory listing cache
vfs/forgetForget cached directory entries
vfs/poll-intervalSet/get poll interval
vfs/listList VFS instances
vfs/queueShow upload queue
vfs/queue-set-expirySet queue item expiry
vfs/statsVFS statistics

options/ — runtime option inspection/modification

EndpointDescription
options/getGet all option blocks
options/setSet option values
options/infoInfo about options
options/localGet local options
options/blocksList option block names

debug/ — runtime profiling

EndpointDescription
debug/set-gc-percentSet GC target percentage
debug/set-block-profile-rateSet block profiling rate
debug/set-mutex-profile-fractionSet mutex profiling fraction
debug/set-soft-memory-limitSet soft memory limit
/debug/pprof/*Standard Go pprof endpoints

rc/ — meta-endpoints

EndpointDescription
rc/listList all registered rc endpoints
rc/noopNo-op, returns params (testing)
rc/noopauthNo-op requiring auth
rc/errorReturns an error (testing)
rc/fatalCauses a fatal error (testing)
rc/panicCauses a panic (testing)

pluginsctl/ — Web GUI plugins

EndpointDescription
pluginsctl/listPluginsList installed plugins
pluginsctl/addPluginInstall a plugin
pluginsctl/removePluginRemove a plugin
pluginsctl/getPluginsForTypeGet plugins by type

cache/ — cache backend-specific (when cache remote used)

EndpointDescription
cache/expireExpire cache entries
cache/fetchPre-fetch into cache
cache/statsCache statistics

Async job mode#

Any endpoint can be called with _async: true parameter. The call returns immediately with a job ID; the actual operation runs in a background goroutine. Job status is polled via job/status. This enables long-running transfers via the JSON-RPC API without blocking the HTTP connection.

Authentication#

  • Basic auth: --rc-user + --rc-pass flags
  • HTTP bearer token: --rc-token
  • No auth: --rc-no-auth (local-only use)
  • Web GUI mode: auto-generates random password if none specified
  • Endpoints can declare AuthRequired: true to require auth even when no-auth mode is set

C Library API (librclone)#

Build target: go build --buildmode=c-shared -o librclone.so github.com/rclone/rclone/librclone

Exported C functions (4 total):

void RcloneInitialize(void);
void RcloneFinalize(void);

struct RcloneRPCResult {
    char *Output;  // JSON string — caller must free
    int   Status;  // HTTP status code (200 = OK)
};

struct RcloneRPCResult RcloneRPC(char *method, char *input);

The RcloneRPC function is a thin shim over the same rc.Calls registry used by rclone rcd. Method is a string like "operations/list", input is a JSON object string. This design ensures the embedded library API is identical to the daemon API — no separate binding layer to maintain.

Bindings exist for Python (python-rclone), PHP, and mobile platforms. All use this same C API.


Protocol Servers (via rclone serve)#

Each protocol server wraps the vfs.VFS abstraction over any rclone remote:

ProtocolServer implPort defaultNotes
HTTPlib/http (chi)8080Read-only file browser
WebDAVgolang.org/x/net/webdav8080Full read/write, macOS Finder compatible
FTPgithub.com/fclairamb/ftpserverlib2121Active/passive modes
SFTPgithub.com/pkg/sftp2022Full read/write
DLNA/UPnPcustom7879Media streaming, TV/device discovery
NFSgithub.com/willscott/go-nfs2049POSIX NFS v3
S3custom S3-compatible8080AWS SDK compatible
resticrestic REST API8080For restic --repo rest:http://...
DockerDocker Volume Plugin APIunix socketDocker --driver rclone

All serve commands accept --addr, --user, --pass, and TLS flags via lib/http. VFS cache settings (--vfs-cache-mode) control write-back behavior.


Backend Plugin API (internal Go)#

The internal extension point for adding storage backends. Each backend implements fs.Fs and self-registers:

// In backend/mybackend/mybackend.go
func init() {
    fs.Register(&fs.RegInfo{
        Name:        "mybackend",
        Description: "My Storage Backend",
        NewFs:       NewFs,
        Options:     []fs.Option{{Name: "api_key", Help: "...", Required: true}},
        Config:      configFn, // optional OAuth flow
    })
}

The NewFs(ctx, name, root string, m configmap.Mapper) (fs.Fs, error) factory receives a config mapper populated from the config file, env vars, and CLI flags. No backend ever reads flags directly.

Optional capabilities are advertised via the Features struct (not via additional interface assertions):

return f, fs.ErrorIsFile
// Features: f.Features().Copy != nil → supports server-side copy

This plugin mechanism is compile-time only: all backends are linked in at build time via blank imports in backend/all/all.go. There is no runtime plugin loading.


API style summary#

API surfaceStyleAuthExtension
CLIcobra + pflagn/aCompile-time: init()
JSON-RPC (rcd)HTTP POST + JSONBasic/TokenCompile-time: rc.Add() in init()
librcloneC FFI thin wrappern/aSame as JSON-RPC
Protocol serversProtocol-nativePer-protocolCompile-time: serve subcommand
Backend pluginGo interface (fs.Fs)n/aCompile-time: fs.Register()

The unifying design principle: one registry pattern, three access modes. The same rc.Calls map is callable via rclone rc (CLI to daemon), POST /operations/... (HTTP to daemon), and RcloneRPC() (in-process C call). Similarly, the same fs.Registry global is consulted whether the user types rclone copy s3:..., calls operations/copyfile via JSON-RPC, or invokes RcloneRPC("operations/copyfile", ...) from Python.