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
| Command | Description |
|---|---|
copy source:path dest:path | Copy src to dst, skipping identical files |
sync source:path dest:path | Sync src to dst (make dst identical) |
move source:path dest:path | Move src to dst |
copyto source:path dest:path | Copy single file/dir with rename |
moveto source:path dest:path | Move single file/dir with rename |
delete remote:path | Remove files in path |
deletefile remote:path | Remove single file |
purge remote:path | Remove directory and all contents |
dedupe [mode] remote:path | Deduplicate files |
bisync source: dest: | Two-way sync |
copyurl https://... dest:path | Copy a URL to remote |
rcat remote:path | Copies stdin to remote |
touch remote:path | Create or update file timestamps |
convmv dest:path --name-transform | Convert filename encoding |
Listing / inspection
| Command | Description |
|---|---|
ls remote:path | List with size and path |
lsd remote:path | List directories only |
lsl remote:path | List with modification time |
lsf remote:path | Formatted listing (configurable) |
lsjson remote:path | List as JSON |
tree remote:path | ncurses-style directory tree |
ncdu remote:path | Interactive disk usage browser |
size remote:path | Count and total size |
about remote: | Show quota/usage for remote |
cat remote:path | Cat files to stdout |
hashsum remote:path | Compute hashes |
md5sum / sha1sum remote:path | Specific hash commands |
Verification
| Command | Description |
|---|---|
check source: dest: | Check src and dst match |
checksum hash file remote: | Check against hashsum file |
cryptcheck remote: cryptedremote: | Check crypt backend |
Filesystem ops
| Command | Description |
|---|---|
mkdir remote:path | Create directory |
rmdir remote:path | Remove empty directory |
rmdirs remote:path | Remove all empty dirs |
cleanup remote: | Remove trashed files |
settier tier remote:path | Set storage class/tier |
link remote:path | Create a public link |
Mount (FUSE)
| Command | Description |
|---|---|
mount remote:path /mnt | FUSE mount (via cgofuse) |
cmount remote:path /mnt | Alternative FUSE via cmount |
nfsmount remote:path /mnt | NFS mount (macOS-focused) |
Serve (rclone as a server)
| Command | Description |
|---|---|
serve http remote:path | HTTP file server |
serve webdav remote:path | WebDAV server |
serve ftp remote:path | FTP server |
serve sftp remote:path | SFTP server |
serve dlna remote:path | DLNA/UPnP media server |
serve nfs remote:path | NFS server |
serve s3 remote:path | S3-compatible server |
serve restic remote:path | Restic REST repository |
serve docker | Docker volume plugin daemon |
Remote control
| Command | Description |
|---|---|
rcd [flags] | Start remote control daemon |
rc method [params...] | Send a call to running rcd |
backend <command> remote:path | Backend-specific commands |
Config management
| Command | Description |
|---|---|
config edit | Interactive 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 name | Delete 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/check | Config file encryption |
config dump / providers / paths | Inspect config |
Utility
| Command | Description |
|---|---|
version | Show version |
selfupdate | Update rclone binary |
obscure password | Obfuscate a password string |
reveal password | Reveal an obfuscated password |
cryptdecode cryptedremote: path | Show original path inside crypt |
authorize backend | OAuth2 authorization flow |
gitannex | git-annex special remote protocol |
archive create/list/extract | Archive operations |
genautocomplete shell | Shell completion scripts |
gendocs output_dir | Generate 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) orGET /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-authdisables 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
| Endpoint | Description |
|---|---|
operations/list | List a directory (fs, remote, options) |
operations/stat | Stat a single file/dir |
operations/about | Quota/usage info for remote |
operations/copyfile | Copy single file (srcFs, srcRemote → dstFs, dstRemote) |
operations/movefile | Move single file |
operations/mkdir | Create directory |
operations/rmdir | Remove empty directory |
operations/purge | Remove directory and contents |
operations/rmdirs | Remove empty directories recursively |
operations/delete | Delete files in path |
operations/deletefile | Delete a single file |
operations/copyurl | Download URL to remote |
operations/uploadfile | Upload via multipart form (HTTP only) |
operations/cleanup | Delete trashed files |
operations/settier | Set storage tier on directory |
operations/settierfile | Set storage tier on file |
operations/size | Compute total size of path |
operations/publiclink | Generate public sharing link |
operations/fsinfo | Metadata about a remote (backend type, features) |
operations/check | Verify src and dst match |
operations/hashsum | Compute hashes for a directory |
operations/hashsumfile | Compute hashes from a hash file |
sync/ — synchronization operations
| Endpoint | Description |
|---|---|
sync/sync | Sync src to dst |
sync/copy | Copy src to dst |
sync/move | Move src to dst |
sync/bisync | Two-way sync |
core/ — runtime control
| Endpoint | Description |
|---|---|
core/bwlimit | Get or set bandwidth limit dynamically |
core/stats | Get transfer statistics |
core/stats-reset | Reset statistics |
core/stats-delete | Delete a stats group |
core/transferred | List completed transfers |
core/group-list | List stats groups |
core/gc | Force garbage collection |
core/memstats | Memory usage statistics |
core/pid | Get process ID |
core/version | Get rclone version |
core/obscure | Obfuscate a string |
core/command | Run any rclone CLI command |
core/du | Disk usage for a path |
core/quit | Terminate the rcd process |
config/ — configuration management
| Endpoint | Description |
|---|---|
config/listremotes | List all configured remotes |
config/get | Get a remote’s config values |
config/set | Update config values |
config/create | Create new remote |
config/update | Update existing remote |
config/delete | Delete a remote |
config/dump | Dump entire config |
config/providers | List available backend types |
config/paths | Show config file paths |
config/setpath | Set config file path |
config/password | Set password on a remote |
config/unlock | Unlock encrypted config |
fscache/ — Fs instance cache
| Endpoint | Description |
|---|---|
fscache/entries | List cached Fs instances |
fscache/clear | Flush Fs cache |
job/ — async job management
| Endpoint | Description |
|---|---|
job/status | Get status of a background job |
job/list | List all jobs |
job/stop | Stop a specific job |
job/stopgroup | Stop all jobs in a group |
job/batch | Execute multiple rc calls in one request |
mount/ — FUSE mount management (when available)
| Endpoint | Description |
|---|---|
mount/mount | Mount a remote |
mount/unmount | Unmount a path |
mount/unmountall | Unmount all mounts |
mount/listmounts | List active mounts |
mount/types | List available mount types |
serve/ — protocol server management
| Endpoint | Description |
|---|---|
serve/start | Start a protocol server |
serve/stop | Stop a specific server |
serve/stopall | Stop all servers |
serve/list | List running servers |
serve/types | List available protocols |
vfs/ — VFS cache management (for mounted/served remotes)
| Endpoint | Description |
|---|---|
vfs/refresh | Refresh directory listing cache |
vfs/forget | Forget cached directory entries |
vfs/poll-interval | Set/get poll interval |
vfs/list | List VFS instances |
vfs/queue | Show upload queue |
vfs/queue-set-expiry | Set queue item expiry |
vfs/stats | VFS statistics |
options/ — runtime option inspection/modification
| Endpoint | Description |
|---|---|
options/get | Get all option blocks |
options/set | Set option values |
options/info | Info about options |
options/local | Get local options |
options/blocks | List option block names |
debug/ — runtime profiling
| Endpoint | Description |
|---|---|
debug/set-gc-percent | Set GC target percentage |
debug/set-block-profile-rate | Set block profiling rate |
debug/set-mutex-profile-fraction | Set mutex profiling fraction |
debug/set-soft-memory-limit | Set soft memory limit |
/debug/pprof/* | Standard Go pprof endpoints |
rc/ — meta-endpoints
| Endpoint | Description |
|---|---|
rc/list | List all registered rc endpoints |
rc/noop | No-op, returns params (testing) |
rc/noopauth | No-op requiring auth |
rc/error | Returns an error (testing) |
rc/fatal | Causes a fatal error (testing) |
rc/panic | Causes a panic (testing) |
pluginsctl/ — Web GUI plugins
| Endpoint | Description |
|---|---|
pluginsctl/listPlugins | List installed plugins |
pluginsctl/addPlugin | Install a plugin |
pluginsctl/removePlugin | Remove a plugin |
pluginsctl/getPluginsForType | Get plugins by type |
cache/ — cache backend-specific (when cache remote used)
| Endpoint | Description |
|---|---|
cache/expire | Expire cache entries |
cache/fetch | Pre-fetch into cache |
cache/stats | Cache 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-passflags - 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: trueto 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:
| Protocol | Server impl | Port default | Notes |
|---|---|---|---|
| HTTP | lib/http (chi) | 8080 | Read-only file browser |
| WebDAV | golang.org/x/net/webdav | 8080 | Full read/write, macOS Finder compatible |
| FTP | github.com/fclairamb/ftpserverlib | 2121 | Active/passive modes |
| SFTP | github.com/pkg/sftp | 2022 | Full read/write |
| DLNA/UPnP | custom | 7879 | Media streaming, TV/device discovery |
| NFS | github.com/willscott/go-nfs | 2049 | POSIX NFS v3 |
| S3 | custom S3-compatible | 8080 | AWS SDK compatible |
| restic | restic REST API | 8080 | For restic --repo rest:http://... |
| Docker | Docker Volume Plugin API | unix socket | Docker --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 copyThis 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 surface | Style | Auth | Extension |
|---|---|---|---|
| CLI | cobra + pflag | n/a | Compile-time: init() |
| JSON-RPC (rcd) | HTTP POST + JSON | Basic/Token | Compile-time: rc.Add() in init() |
| librclone | C FFI thin wrapper | n/a | Same as JSON-RPC |
| Protocol servers | Protocol-native | Per-protocol | Compile-time: serve subcommand |
| Backend plugin | Go interface (fs.Fs) | n/a | Compile-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.