> For the complete documentation index, see [llms.txt](https://seanime.gitbook.io/seanime-extensions/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://seanime.gitbook.io/seanime-extensions/plugins/ui/downloading/torrent-client.md).

# Torrent Client

## Permission

{% hint style="warning" %}
`torrent-client` permission is required.
{% endhint %}

<pre class="language-json" data-title="my-plugin.json"><code class="lang-json">{
    //...
    "plugin": {
        "permissions": {
<strong>            "scopes": ["torrent-client"],
</strong>        }
    }
}
</code></pre>

## Core Methods

### getTorrents

```
getTorrents()
```

Retrieves a list of all torrents in the torrent client.

Example:

```javascript
// Get all torrents from the client
try {
  const torrents = await ctx.torrentClient.getTorrents()
  console.log("Retrieved torrents:", torrents)
} catch (error) {
  console.error("Error getting torrents:", error)
}
```

### getActiveTorrents

```
getActiveTorrents()
```

Retrieves a list of active torrents (downloading/uploading) from the torrent client.

Example:

```javascript
// Get only active torrents
try {
  const activeTorrents = await ctx.torrentClient.getActiveTorrents()
  console.log("Active torrents:", activeTorrents)
} catch (error) {
  console.error("Error getting active torrents:", error)
}
```

### addMagnets

```
addMagnets(magnets, dest)
```

Adds magnet links to the torrent client.

**Parameters**:

* `magnets`: string\[] - Array of magnet links
* `dest`: string - Destination path for downloaded files

Example:

```javascript
// Add magnet links to the torrent client
try {
  await ctx.torrentClient.addMagnets(
    ["magnet:?xt=urn:btih:xxxxxx", "magnet:?xt=urn:btih:yyyyyy"],
    "/downloads/anime"
  )
  console.log("Magnets added successfully")
} catch (error) {
  console.error("Error adding magnets:", error)
}
```

### removeTorrents

```
removeTorrents(hashes)
```

Removes torrents from the client.

**Parameters**:

* `hashes`: string\[] - Array of torrent hashes to remove

Example:

```javascript
// Remove torrents from the client
try {
  await ctx.torrentClient.removeTorrents(["abc123def456", "xyz789uvw"])
  console.log("Torrents removed successfully")
} catch (error) {
  console.error("Error removing torrents:", error)
}
```

### pauseTorrents

```
pauseTorrents(hashes)
```

Pauses specified torrents.

**Parameters**:

* `hashes`: string\[] - Array of torrent hashes to pause

Example:

```javascript
// Pause specific torrents
try {
  await ctx.torrentClient.pauseTorrents(["abc123def456", "xyz789uvw"])
  console.log("Torrents paused successfully")
} catch (error) {
  console.error("Error pausing torrents:", error)
}
```

### resumeTorrents

```
resumeTorrents(hashes)
```

Resumes specified torrents.

**Parameters**:

* `hashes`: string\[] - Array of torrent hashes to resume

Example:

```javascript
// Resume specific torrents
try {
  await ctx.torrentClient.resumeTorrents(["abc123def456", "xyz789uvw"])
  console.log("Torrents resumed successfully")
} catch (error) {
  console.error("Error resuming torrents:", error)
}
```

### deselectFiles

```
deselectFiles(hash, indices)
```

Deselects specific files within a torrent.

**Parameters**:

* `hash`: string - Hash of the torrent
* `indices`: number\[] - Array of file indices to deselect

Example:

```javascript
// Deselect specific files in a torrent
try {
  await ctx.torrentClient.deselectFiles("abc123def456", [0, 2, 5])
  console.log("Files deselected successfully")
} catch (error) {
  console.error("Error deselecting files:", error)
}
```

### getFiles

```
getFiles(hash)
```

Retrieves all files within a specific torrent.

**Parameters**:

* `hash`: string - Hash of the torrent

Example:

```javascript
// Get all files in a torrent
try {
  const files = await ctx.torrentClient.getFiles("abc123def456")
  console.log("Torrent files:", files)
} catch (error) {
  console.error("Error getting files:", error)
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://seanime.gitbook.io/seanime-extensions/plugins/ui/downloading/torrent-client.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
