Table of Contents

Interface ITorrentsClient

Namespace
TorBoxSDK.Main.Torrents
Assembly
TorBoxSDK.dll

Defines operations for managing torrents through the TorBox Main API.

public interface ITorrentsClient

Methods

AsyncCreateTorrentAsync(CreateTorrentRequest, CancellationToken)

Creates a new torrent download with asynchronous server-side processing.

Task<TorBoxResponse<Torrent>> AsyncCreateTorrentAsync(CreateTorrentRequest request, CancellationToken cancellationToken = default)

Parameters

request CreateTorrentRequest

The torrent creation request containing the magnet URI or file bytes.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<TorBoxResponse<Torrent>>

The created torrent details.

Exceptions

ArgumentNullException

Thrown when request is null.

TorBoxException

Thrown when the API returns an error.

CheckCachedAsync(IReadOnlyList<string>, CheckCachedOptions?, CancellationToken)

Checks whether one or more torrent hashes are cached on TorBox (GET).

Task<TorBoxResponse<CheckCached>> CheckCachedAsync(IReadOnlyList<string> hashes, CheckCachedOptions? options = null, CancellationToken cancellationToken = default)

Parameters

hashes IReadOnlyList<string>

The list of hashes to check for cache availability.

options CheckCachedOptions

Optional cache check parameters.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<TorBoxResponse<CheckCached>>

The cache status data.

Exceptions

ArgumentNullException

Thrown when hashes is null.

TorBoxException

Thrown when the API returns an error.

CheckCachedByPostAsync(CheckCachedRequest, CancellationToken)

Checks whether one or more torrent hashes are cached on TorBox (POST).

Task<TorBoxResponse<CheckCached>> CheckCachedByPostAsync(CheckCachedRequest request, CancellationToken cancellationToken = default)

Parameters

request CheckCachedRequest

The cache check request containing hashes and options.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<TorBoxResponse<CheckCached>>

The cache status data.

Exceptions

ArgumentNullException

Thrown when request is null.

TorBoxException

Thrown when the API returns an error.

ControlTorrentAsync(ControlTorrentRequest, CancellationToken)

Performs a control operation on a torrent (delete, pause, resume, etc.).

Task<TorBoxResponse> ControlTorrentAsync(ControlTorrentRequest request, CancellationToken cancellationToken = default)

Parameters

request ControlTorrentRequest

The control operation request.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<TorBoxResponse>

The API response.

Exceptions

ArgumentNullException

Thrown when request is null.

TorBoxException

Thrown when the API returns an error.

CreateTorrentAsync(CreateTorrentRequest, CancellationToken)

Creates a new torrent download from a magnet URI or torrent file.

Task<TorBoxResponse<Torrent>> CreateTorrentAsync(CreateTorrentRequest request, CancellationToken cancellationToken = default)

Parameters

request CreateTorrentRequest

The torrent creation request containing the magnet URI or file bytes.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<TorBoxResponse<Torrent>>

The created torrent details.

Exceptions

ArgumentNullException

Thrown when request is null.

TorBoxException

Thrown when the API returns an error.

EditTorrentAsync(EditTorrentRequest, CancellationToken)

Edits the properties of an existing torrent.

Task<TorBoxResponse> EditTorrentAsync(EditTorrentRequest request, CancellationToken cancellationToken = default)

Parameters

request EditTorrentRequest

The edit request containing the new property values.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<TorBoxResponse>

The API response.

Exceptions

ArgumentNullException

Thrown when request is null.

TorBoxException

Thrown when the API returns an error.

ExportDataAsync(long, string?, CancellationToken)

Exports data for a torrent in the specified format.

Task<TorBoxResponse<string>> ExportDataAsync(long torrentId, string? exportType = null, CancellationToken cancellationToken = default)

Parameters

torrentId long

The unique identifier of the torrent to export data for.

exportType string

The export type format, or null for the default format.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<TorBoxResponse<string>>

The exported data as a string.

Exceptions

TorBoxException

Thrown when the API returns an error.

GetMyTorrentListAsync(GetMyListOptions?, CancellationToken)

Retrieves the authenticated user's torrent list.

Task<TorBoxResponse<IReadOnlyList<Torrent>>> GetMyTorrentListAsync(GetMyListOptions? options = null, CancellationToken cancellationToken = default)

Parameters

options GetMyListOptions

Optional query parameters for filtering and pagination.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<TorBoxResponse<IReadOnlyList<Torrent>>>

A list of torrents, or a single torrent if an ID is specified in options.

Exceptions

TorBoxException

Thrown when the API returns an error.

GetTorrentInfoAsync(string, GetTorrentInfoOptions?, CancellationToken)

Retrieves torrent metadata from a hash.

Task<TorBoxResponse<TorrentInfo>> GetTorrentInfoAsync(string hash, GetTorrentInfoOptions? options = null, CancellationToken cancellationToken = default)

Parameters

hash string

The info hash of the torrent.

options GetTorrentInfoOptions

Optional torrent info parameters.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<TorBoxResponse<TorrentInfo>>

The torrent metadata information.

Exceptions

ArgumentNullException

Thrown when hash is null.

ArgumentException

Thrown when hash is empty.

TorBoxException

Thrown when the API returns an error.

GetTorrentInfoByFileAsync(TorrentInfoRequest, CancellationToken)

Retrieves torrent metadata from a torrent file, magnet URI, or info hash via the POST endpoint.

Task<TorBoxResponse<TorrentInfo>> GetTorrentInfoByFileAsync(TorrentInfoRequest request, CancellationToken cancellationToken = default)

Parameters

request TorrentInfoRequest

The torrent info request containing the file bytes, magnet URI, hash, and options.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<TorBoxResponse<TorrentInfo>>

The torrent metadata information.

Exceptions

ArgumentNullException

Thrown when request is null.

TorBoxException

Thrown when the API returns an error.

MagnetToFileAsync(MagnetToFileRequest, CancellationToken)

Converts a magnet link to a torrent file.

Task<TorBoxResponse<string>> MagnetToFileAsync(MagnetToFileRequest request, CancellationToken cancellationToken = default)

Parameters

request MagnetToFileRequest

The request containing the magnet link to convert.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<TorBoxResponse<string>>

The torrent file data as a string.

Exceptions

ArgumentNullException

Thrown when request is null.

TorBoxException

Thrown when the API returns an error.

RequestDownloadAsync(long, RequestDownloadOptions?, CancellationToken)

Requests a download link for a torrent.

Task<TorBoxResponse<string>> RequestDownloadAsync(long torrentId, RequestDownloadOptions? options = null, CancellationToken cancellationToken = default)

Parameters

torrentId long

The unique identifier of the torrent to download.

options RequestDownloadOptions

Optional download request options.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<TorBoxResponse<string>>

The download URL as a string.

Exceptions

TorBoxException

Thrown when the API returns an error.