title: "Remote Control / API" description: "Remote controlling rclone with its API"
Remote controlling rclone with its API
If rclone is run with the --rc flag then it starts an HTTP server
which can be used to remote control rclone using its API.
You can either use the rclone rc command to access the API or use HTTP directly.
If you just want to run a remote control then see the rcd command.
Supported parameters
--rc
Flag to start the http server listen on remote requests
--rc-addr=IP
IPaddress:Port or :Port to bind server to. (default "localhost:5572")
--rc-cert=KEY
SSL PEM key (concatenation of certificate and CA certificate)
--rc-client-ca=PATH
Client certificate authority to verify clients with
--rc-htpasswd=PATH
htpasswd file - if not provided no authentication is done
--rc-key=PATH
SSL PEM Private key
--rc-max-header-bytes=VALUE
Maximum size of request header (default 4096)
--rc-user=VALUE
User name for authentication.
--rc-pass=VALUE
Password for authentication.
--rc-realm=VALUE
Realm for authentication (default "rclone")
--rc-server-read-timeout=DURATION
Timeout for server reading data (default 1h0m0s)
--rc-server-write-timeout=DURATION
Timeout for server writing data (default 1h0m0s)
--rc-serve
Enable the serving of remote objects via the HTTP interface. This means objects will be accessible at http://127.0.0.1:5572/ by default, so you can browse to http://127.0.0.1:5572/ or http://127.0.0.1:5572/* to see a listing of the remotes. Objects may be requested from remotes using this syntax http://127.0.0.1:5572/[remote:path]/path/to/object
Default Off.
--rc-files /path/to/directory
Path to local files to serve on the HTTP server.
If this is set then rclone will serve the files in that directory. It will also open the root in the web browser if specified. This is for implementing browser based GUIs for rclone functions.
If --rc-user or --rc-pass is set then the URL that is opened will
have the authorization in the URL in the http://user:pass@localhost/
style.
Default Off.
--rc-enable-metrics
Enable OpenMetrics/Prometheus compatible endpoint at /metrics.
Default Off.
--rc-web-gui
Set this flag to serve the default web gui on the same port as rclone.
Default Off.
--rc-allow-origin
Set the allowed Access-Control-Allow-Origin for rc requests.
Can be used with --rc-web-gui if the rclone is running on different IP than the web-gui.
Default is IP address on which rc is running.
--rc-web-fetch-url
Set the URL to fetch the rclone-web-gui files from.
Default https://api.github.com/repos/rclone/rclone-webui-react/releases/latest.
--rc-web-gui-update
Set this flag to check and update rclone-webui-react from the rc-web-fetch-url.
Default Off.
--rc-web-gui-force-update
Set this flag to force update rclone-webui-react from the rc-web-fetch-url.
Default Off.
--rc-web-gui-no-open-browser
Set this flag to disable opening browser automatically when using web-gui.
Default Off.
--rc-job-expire-duration=DURATION
Expire finished async jobs older than DURATION (default 60s).
--rc-job-expire-interval=DURATION
Interval duration to check for expired async jobs (default 10s).
--rc-no-auth
By default rclone will require authorisation to have been set up on
the rc interface in order to use any methods which access any rclone
remotes. Eg operations/list is denied as it involved creating a
remote as is sync/copy.
If this is set then no authorisation will be required on the server to
use these methods. The alternative is to use --rc-user and
--rc-pass and use these credentials in the request.
Default Off.
Accessing the remote control via the rclone rc command {#api-rc}
Rclone itself implements the remote control protocol in its rclone rc command.
You can use it like this
$ rclone rc rc/noop param1=one param2=two
{
"param1": "one",
"param2": "two"
}
Run rclone rc on its own to see the help for the installed remote
control commands.
JSON input
rclone rc also supports a --json flag which can be used to send
more complicated input parameters.
$ rclone rc --json '{ "p1": [1,"2",null,4], "p2": { "a":1, "b":2 } }' rc/noop
{
"p1": [
1,
"2",
null,
4
],
"p2": {
"a": 1,
"b": 2
}
}
If the parameter being passed is an object then it can be passed as a
JSON string rather than using the --json flag which simplifies the
command line.
rclone rc operations/list fs=/tmp remote=test opt='{"showHash": true}'
Rather than
rclone rc operations/list --json '{"fs": "/tmp", "remote": "test", "opt": {"showHash": true}}'
Special parameters
The rc interface supports some special parameters which apply to
all commands. These start with _ to show they are different.
Running asynchronous jobs with _async = true
Each rc call is classified as a job and it is assigned its own id. By default jobs are executed immediately as they are created or synchronously.
If _async has a true value when supplied to an rc call then it will
return immediately with a job id and the task will be run in the
background. The job/status call can be used to get information of
the background job. The job can be queried for up to 1 minute after
it has finished.
It is recommended that potentially long running jobs, e.g. sync/sync,
sync/copy, sync/move, operations/purge are run with the _async
flag to avoid any potential problems with the HTTP request and
response timing out.
Starting a job with the _async flag:
$ rclone rc --json '{ "p1": [1,"2",null,4], "p2": { "a":1, "b":2 }, "_async": true }' rc/noop
{
"jobid": 2
}
Query the status to see if the job has finished. For more information
on the meaning of these return parameters see the job/status call.
$ rclone rc --json '{ "jobid":2 }' job/status
{
"duration": 0.000124163,
"endTime": "2018-10-27T11:38:07.911245881+01:00",
"error": "",
"finished": true,
"id": 2,
"output": {
"_async": true,
"p1": [
1,
"2",
null,
4
],
"p2": {
"a": 1,
"b": 2
}
},
"startTime": "2018-10-27T11:38:07.911121728+01:00",
"success": true
}
job/list can be used to show the running or recently completed jobs
$ rclone rc job/list
{
"jobids": [
2
]
}
Setting config flags with _config
If you wish to set config (the equivalent of the global flags) for the
duration of an rc call only then pass in the _config parameter.
This should be in the same format as the config key returned by
options/get.
For example, if you wished to run a sync with the --checksum
parameter, you would pass this parameter in your JSON blob.
"_config":{"CheckSum": true}
If using rclone rc this could be passed as
rclone rc operations/sync ... _config='{"CheckSum": true}'
Any config parameters you don't set will inherit the global defaults which were set with command line flags or environment variables.
Note that it is possible to set some values as strings or integers -
see data types for more info. Here is an example
setting the equivalent of --buffer-size in string or integer format.
"_config":{"BufferSize": "42M"}
"_config":{"BufferSize": 44040192}
If you wish to check the _config assignment has worked properly then
calling options/local will show what the value got set to.
Setting filter flags with _filter
If you wish to set filters for the duration of an rc call only then
pass in the _filter parameter.
This should be in the same format as the filter key returned by
options/get.
For example, if you wished to run a sync with these flags
--max-size 1M --max-age 42s --include "a" --include "b"
you would pass this parameter in your JSON blob.
"_filter":{"MaxSize":"1M", "IncludeRule":["a","b"], "MaxAge":"42s"}
If using rclone rc this could be passed as
rclone rc ... _filter='{"MaxSize":"1M", "IncludeRule":["a","b"], "MaxAge":"42s"}'
Any filter parameters you don't set will inherit the global defaults which were set with command line flags or environment variables.
Note that it is possible to set some values as strings or integers -
see data types for more info. Here is an example
setting the equivalent of --buffer-size in string or integer format.
"_filter":{"MinSize": "42M"}
"_filter":{"MinSize": 44040192}
If you wish to check the _filter assignment has worked properly then
calling options/local will show what the value got set to.
Assigning operations to groups with _group = value
Each rc call has its own stats group for tracking its metrics. By default
grouping is done by the composite group name from prefix job/ and id of the
job like so job/1.
If _group has a value then stats for that request will be grouped under that
value. This allows caller to group stats under their own name.
Stats for specific group can be accessed by passing group to core/stats:
$ rclone rc --json '{ "group": "job/1" }' core/stats
{
"speed": 12345
...
}
Data types {#data-types}
When the API returns types, these will mostly be straight forward integer, string or boolean types.
However some of the types returned by the options/get
call and taken by the options/set calls as well as the
vfsOpt, mountOpt and the _config parameters.
Duration- these are returned as an integer duration in nanoseconds. They may be set as an integer, or they may be set with time string, eg "5s". See the options section for more info.Size- these are returned as an integer number of bytes. They may be set as an integer or they may be set with a size suffix string, eg "10M". See the options section for more info.- Enumerated type (such as
CutoffMode,DumpFlags,LogLevel,VfsCacheMode- these will be returned as an integer and may be set as an integer but more conveniently they can be set as a string, eg "HARD" forCutoffModeorDEBUGforLogLevel. BandwidthSpec- this will be set and returned as a string, eg "1M".
Specifying remotes to work on
Remotes are specified with the fs=, srcFs=, dstFs=
parameters depending on the command being used.
The parameters can be a string as per the rest of rclone, eg
s3:bucket/path or :sftp:/my/dir. They can also be specified as
JSON blobs.
If specifyng a JSON blob it should be a object mapping strings to strings. These values will be used to configure the remote. There are 3 special values which may be set:
type- set totypeto specify a remote called:type:_name- set tonameto specify a remote calledname:_root- sets the root of the remote - may be empty
One of _name or type should normally be set. If the local
backend is desired then type should be set to local. If _root
isn't specified then it defaults to the root of the remote.
For example this JSON is equivalent to remote:/tmp
{
"_name": "remote",
"_path": "/tmp"
}
And this is equivalent to :sftp,host='example.com':/tmp
{
"type": "sftp",
"host": "example.com",
"_path": "/tmp"
}
And this is equivalent to /tmp/dir
{
type = "local",
_ path = "/tmp/dir"
}
Supported commands
{{< rem autogenerated start "- run make rcdocs - don't edit here" >}}
backend/command: Runs a backend command. {#backend-command}
This takes the following parameters
- command - a string with the command name
- fs - a remote name string e.g. "drive:"
- arg - a list of arguments for the backend command
- opt - a map of string to string of options
Returns
- result - result from the backend command
For example
rclone rc backend/command command=noop fs=. -o echo=yes -o blue -a path1 -a path2
Returns
{
"result": {
"arg": [
"path1",
"path2"
],
"name": "noop",
"opt": {
"blue": "",
"echo": "yes"
}
}
}
Note that this is the direct equivalent of using this "backend" command:
rclone backend noop . -o echo=yes -o blue path1 path2
Note that arguments must be preceded by the "-a" flag
See the backend command for more information.
Authentication is required for this call.
cache/expire: Purge a remote from cache {#cache-expire}
Purge a remote from the cache backend. Supports either a directory or a file. Params:
- remote = path to remote (required)
- withData = true/false to delete cached data (chunks) as well (optional)
Eg
rclone rc cache/expire remote=path/to/sub/folder/
rclone rc cache/expire remote=/ withData=true
cache/fetch: Fetch file chunks {#cache-fetch}
Ensure the specified file chunks are cached on disk.
The chunks= parameter specifies the file chunks to check. It takes a comma separated list of array slice indices. The slice indices are similar to Python slices: start[:end]
start is the 0 based chunk number from the beginning of the file to fetch inclusive. end is 0 based chunk number from the beginning of the file to fetch exclusive.
Lines 1–500 of 1803. Load more
--- title: "Remote Control / API" description: "Remote controlling rclone with its API" --- # Remote controlling rclone with its API If rclone is run with the `--rc` flag then it starts an HTTP server which can be used to remote control rclone using its API. You can either use the [rclone rc](#api-rc) command to access the API or [use HTTP directly](#api-http). If you just want to run a remote control then see the [rcd command](/commands/rclone_rcd/). ## Supported parameters ### --rc Flag to start the http server listen on remote requests ### --rc-addr=IP IPaddress:Port or :Port to bind server to. (default "localhost:5572") ### --rc-cert=KEY SSL PEM key (concatenation of certificate and CA certificate) ### --rc-client-ca=PATH Client certificate authority to verify clients with ### --rc-htpasswd=PATH htpasswd file - if not provided no authentication is done ### --rc-key=PATH SSL PEM Private key ### --rc-max-header-bytes=VALUE Maximum size of request header (default 4096) ### --rc-user=VALUE User name for authentication. ### --rc-pass=VALUE Password for authentication. ### --rc-realm=VALUE Realm for authentication (default "rclone") ### --rc-server-read-timeout=DURATION Timeout for server reading data (default 1h0m0s) ### --rc-server-write-timeout=DURATION Timeout for server writing data (default 1h0m0s) ### --rc-serve Enable the serving of remote objects via the HTTP interface. This means objects will be accessible at http://127.0.0.1:5572/ by default, so you can browse to http://127.0.0.1:5572/ or http://127.0.0.1:5572/* to see a listing of the remotes. Objects may be requested from remotes using this syntax http://127.0.0.1:5572/[remote:path]/path/to/object Default Off. ### --rc-files /path/to/directory Path to local files to serve on the HTTP server. If this is set then rclone will serve the files in that directory. It will also open the root in the web browser if specified. This is for implementing browser based GUIs for rclone functions. If `--rc-user` or `--rc-pass` is set then the URL that is opened will have the authorization in the URL in the `http://user:pass@localhost/` style. Default Off. ### --rc-enable-metrics Enable OpenMetrics/Prometheus compatible endpoint at `/metrics`. Default Off. ### --rc-web-gui Set this flag to serve the default web gui on the same port as rclone. Default Off. ### --rc-allow-origin Set the allowed Access-Control-Allow-Origin for rc requests. Can be used with --rc-web-gui if the rclone is running on different IP than the web-gui. Default is IP address on which rc is running. ### --rc-web-fetch-url Set the URL to fetch the rclone-web-gui files from. Default https://api.github.com/repos/rclone/rclone-webui-react/releases/latest. ### --rc-web-gui-update Set this flag to check and update rclone-webui-react from the rc-web-fetch-url. Default Off. ### --rc-web-gui-force-update Set this flag to force update rclone-webui-react from the rc-web-fetch-url. Default Off. ### --rc-web-gui-no-open-browser Set this flag to disable opening browser automatically when using web-gui. Default Off. ### --rc-job-expire-duration=DURATION Expire finished async jobs older than DURATION (default 60s). ### --rc-job-expire-interval=DURATION Interval duration to check for expired async jobs (default 10s). ### --rc-no-auth By default rclone will require authorisation to have been set up on the rc interface in order to use any methods which access any rclone remotes. Eg `operations/list` is denied as it involved creating a remote as is `sync/copy`. If this is set then no authorisation will be required on the server to use these methods. The alternative is to use `--rc-user` and `--rc-pass` and use these credentials in the request. Default Off. ## Accessing the remote control via the rclone rc command {#api-rc} Rclone itself implements the remote control protocol in its `rclone rc` command. You can use it like this ``` $ rclone rc rc/noop param1=one param2=two { "param1": "one", "param2": "two" } ``` Run `rclone rc` on its own to see the help for the installed remote control commands. ## JSON input `rclone rc` also supports a `--json` flag which can be used to send more complicated input parameters. ``` $ rclone rc --json '{ "p1": [1,"2",null,4], "p2": { "a":1, "b":2 } }' rc/noop { "p1": [ 1, "2", null, 4 ], "p2": { "a": 1, "b": 2 } } ``` If the parameter being passed is an object then it can be passed as a JSON string rather than using the `--json` flag which simplifies the command line. ``` rclone rc operations/list fs=/tmp remote=test opt='{"showHash": true}' ``` Rather than ``` rclone rc operations/list --json '{"fs": "/tmp", "remote": "test", "opt": {"showHash": true}}' ``` ## Special parameters The rc interface supports some special parameters which apply to **all** commands. These start with `_` to show they are different. ### Running asynchronous jobs with _async = true Each rc call is classified as a job and it is assigned its own id. By default jobs are executed immediately as they are created or synchronously. If `_async` has a true value when supplied to an rc call then it will return immediately with a job id and the task will be run in the background. The `job/status` call can be used to get information of the background job. The job can be queried for up to 1 minute after it has finished. It is recommended that potentially long running jobs, e.g. `sync/sync`, `sync/copy`, `sync/move`, `operations/purge` are run with the `_async` flag to avoid any potential problems with the HTTP request and response timing out. Starting a job with the `_async` flag: ``` $ rclone rc --json '{ "p1": [1,"2",null,4], "p2": { "a":1, "b":2 }, "_async": true }' rc/noop { "jobid": 2 } ``` Query the status to see if the job has finished. For more information on the meaning of these return parameters see the `job/status` call. ``` $ rclone rc --json '{ "jobid":2 }' job/status { "duration": 0.000124163, "endTime": "2018-10-27T11:38:07.911245881+01:00", "error": "", "finished": true, "id": 2, "output": { "_async": true, "p1": [ 1, "2", null, 4 ], "p2": { "a": 1, "b": 2 } }, "startTime": "2018-10-27T11:38:07.911121728+01:00", "success": true } ``` `job/list` can be used to show the running or recently completed jobs ``` $ rclone rc job/list { "jobids": [ 2 ] } ``` ### Setting config flags with _config If you wish to set config (the equivalent of the global flags) for the duration of an rc call only then pass in the `_config` parameter. This should be in the same format as the `config` key returned by [options/get](#options-get). For example, if you wished to run a sync with the `--checksum` parameter, you would pass this parameter in your JSON blob. "_config":{"CheckSum": true} If using `rclone rc` this could be passed as rclone rc operations/sync ... _config='{"CheckSum": true}' Any config parameters you don't set will inherit the global defaults which were set with command line flags or environment variables. Note that it is possible to set some values as strings or integers - see [data types](/#data-types) for more info. Here is an example setting the equivalent of `--buffer-size` in string or integer format. "_config":{"BufferSize": "42M"} "_config":{"BufferSize": 44040192} If you wish to check the `_config` assignment has worked properly then calling `options/local` will show what the value got set to. ### Setting filter flags with _filter If you wish to set filters for the duration of an rc call only then pass in the `_filter` parameter. This should be in the same format as the `filter` key returned by [options/get](#options-get). For example, if you wished to run a sync with these flags --max-size 1M --max-age 42s --include "a" --include "b" you would pass this parameter in your JSON blob. "_filter":{"MaxSize":"1M", "IncludeRule":["a","b"], "MaxAge":"42s"} If using `rclone rc` this could be passed as rclone rc ... _filter='{"MaxSize":"1M", "IncludeRule":["a","b"], "MaxAge":"42s"}' Any filter parameters you don't set will inherit the global defaults which were set with command line flags or environment variables. Note that it is possible to set some values as strings or integers - see [data types](/#data-types) for more info. Here is an example setting the equivalent of `--buffer-size` in string or integer format. "_filter":{"MinSize": "42M"} "_filter":{"MinSize": 44040192} If you wish to check the `_filter` assignment has worked properly then calling `options/local` will show what the value got set to. ### Assigning operations to groups with _group = value Each rc call has its own stats group for tracking its metrics. By default grouping is done by the composite group name from prefix `job/` and id of the job like so `job/1`. If `_group` has a value then stats for that request will be grouped under that value. This allows caller to group stats under their own name. Stats for specific group can be accessed by passing `group` to `core/stats`: ``` $ rclone rc --json '{ "group": "job/1" }' core/stats { "speed": 12345 ... } ``` ## Data types {#data-types} When the API returns types, these will mostly be straight forward integer, string or boolean types. However some of the types returned by the [options/get](#options-get) call and taken by the [options/set](#options-set) calls as well as the `vfsOpt`, `mountOpt` and the `_config` parameters. - `Duration` - these are returned as an integer duration in nanoseconds. They may be set as an integer, or they may be set with time string, eg "5s". See the [options section](/docs/#options) for more info. - `Size` - these are returned as an integer number of bytes. They may be set as an integer or they may be set with a size suffix string, eg "10M". See the [options section](/docs/#options) for more info. - Enumerated type (such as `CutoffMode`, `DumpFlags`, `LogLevel`, `VfsCacheMode` - these will be returned as an integer and may be set as an integer but more conveniently they can be set as a string, eg "HARD" for `CutoffMode` or `DEBUG` for `LogLevel`. - `BandwidthSpec` - this will be set and returned as a string, eg "1M". ## Specifying remotes to work on Remotes are specified with the `fs=`, `srcFs=`, `dstFs=` parameters depending on the command being used. The parameters can be a string as per the rest of rclone, eg `s3:bucket/path` or `:sftp:/my/dir`. They can also be specified as JSON blobs. If specifyng a JSON blob it should be a object mapping strings to strings. These values will be used to configure the remote. There are 3 special values which may be set: - `type` - set to `type` to specify a remote called `:type:` - `_name` - set to `name` to specify a remote called `name:` - `_root` - sets the root of the remote - may be empty One of `_name` or `type` should normally be set. If the `local` backend is desired then `type` should be set to `local`. If `_root` isn't specified then it defaults to the root of the remote. For example this JSON is equivalent to `remote:/tmp` ``` { "_name": "remote", "_path": "/tmp" } ``` And this is equivalent to `:sftp,host='example.com':/tmp` ``` { "type": "sftp", "host": "example.com", "_path": "/tmp" } ``` And this is equivalent to `/tmp/dir` ``` { type = "local", _ path = "/tmp/dir" } ``` ## Supported commands {{< rem autogenerated start "- run make rcdocs - don't edit here" >}} ### backend/command: Runs a backend command. {#backend-command} This takes the following parameters - command - a string with the command name - fs - a remote name string e.g. "drive:" - arg - a list of arguments for the backend command - opt - a map of string to string of options Returns - result - result from the backend command For example rclone rc backend/command command=noop fs=. -o echo=yes -o blue -a path1 -a path2 Returns ``` { "result": { "arg": [ "path1", "path2" ], "name": "noop", "opt": { "blue": "", "echo": "yes" } } } ``` Note that this is the direct equivalent of using this "backend" command: rclone backend noop . -o echo=yes -o blue path1 path2 Note that arguments must be preceded by the "-a" flag See the [backend](/commands/rclone_backend/) command for more information. **Authentication is required for this call.** ### cache/expire: Purge a remote from cache {#cache-expire} Purge a remote from the cache backend. Supports either a directory or a file. Params: - remote = path to remote (required) - withData = true/false to delete cached data (chunks) as well (optional) Eg rclone rc cache/expire remote=path/to/sub/folder/ rclone rc cache/expire remote=/ withData=true ### cache/fetch: Fetch file chunks {#cache-fetch} Ensure the specified file chunks are cached on disk. The chunks= parameter specifies the file chunks to check. It takes a comma separated list of array slice indices. The slice indices are similar to Python slices: start[:end] start is the 0 based chunk number from the beginning of the file to fetch inclusive. end is 0 based chunk number from the beginning of the file to fetch exclusive.