Welcome to transmission-rpc’s documentation!

transmission-rpc is a python3 library to help your control your transmission daemon remotely.

quick start

import requests

from transmission_rpc import Client

torrent_url = "https://github.com/trim21/transmission-rpc/raw/v4.1.0/tests/fixtures/iso.torrent"
c = Client(host="localhost", port=9091, username="transmission", password="password")
c.add_torrent(torrent_url)

########


c = Client(username="transmission", password="password")

torrent_url = "magnet:?xt=urn:btih:e84213a794f3ccd890382a54a64ca68b7e925433&dn=ubuntu-18.04.1-desktop-amd64.iso"
c.add_torrent(torrent_url)

########


c = Client(username="trim21", password="123456")

torrent_url = "https://github.com/trim21/transmission-rpc/raw/v4.1.0/tests/fixtures/iso.torrent"
r = requests.get(torrent_url)

# client will base64 the torrent content for you.
c.add_torrent(r.content)

# or use a file-like object
with open("a", "wb") as f:
    f.write(r.content)
with open("a", "rb") as f:
    c.add_torrent(f)

See also

transmission_rpc.client.Client.add_torrent()

Example

Filter files

from transmission_rpc import Client

client = Client()

t = client.get_torrent(0)

client.change_torrent(
    t.hashString,
    files_unwanted=[f.id for f in t.get_files() if f.name.endswith(".txt")],
    priority_high=[f.id for f in t.get_files() if f.name.endswith(".mp4")],
    priority_low=[f.id for f in t.get_files() if f.name.endswith(".txt")],
)

Move Torrent Data

from transmission_rpc import Client

client = Client()

t = client.get_torrent(0)

client.move_torrent_data(t.hashString, location="/home/trim21/downloads/completed/")

Set Upload/Download Speed Limit

from transmission_rpc import Client

client = Client()

client.change_torrent(
    0,
    upload_limited=True,  # don't forget this
    upload_limit=100,
    download_limited=True,
    download_limit=100,
)

Arguments

Each method has it own arguments. You can pass arguments as kwargs when you call methods.

But in python, - can’t be used in a variable name, so you need to replace - with _.

For example, torrent-add method support arguments download-dir, you should call method like this.

from transmission_rpc import Client

Client().add_torrent(torrent_url, download_dir='/path/to/download/dir')

transmission-rpc will put {"download-dir": "/path/to/download/dir"} in arguments.

you can find rpc version by transmission version from transmission rpc docs

Indices and tables