Python

Control Rclone from Python using the remote control HTTP API with requests.

Python's requests library provides an elegant way to interact with Rclone's remote control API.

For more complex use cases, consider using a dedicated library.

Usage

import requests

response = requests.get('http://localhost:5572/')
print(response.json())

Making a POST request with parameters:

import requests

response = requests.post(
    'http://localhost:5572/core/stats',
    json={}
)
print(response.json())

Libraries

rclone-api

A high-performance Python wrapper for Rclone with aggressive transfer defaults, VFS support, and database integration.

pip install rclone-api
from rclone_api import Rclone, Config

RCLONE_CONFIG = Config("""
[myremote]
type = s3
access_key_id = YOUR_ACCESS_KEY
secret_access_key = YOUR_SECRET_KEY
""")

rclone = Rclone(RCLONE_CONFIG)

# List files with glob pattern
listing = rclone.ls("myremote:bucket/path", glob="*.png")
for file in listing.files:
    print(file.name, file.size)

# Copy files
rclone.copy("myremote:src/path", "myremote:dst/path")

# Check if directories are in sync
is_synced = rclone.is_synced("myremote:src", "myremote:dst")

How is this guide?