Interface ITorrentsClient
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
requestCreateTorrentRequestThe torrent creation request containing the magnet URI or file bytes.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<TorBoxResponse<Torrent>>
The created torrent details.
Exceptions
- ArgumentNullException
Thrown when
requestis 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
hashesIReadOnlyList<string>The list of hashes to check for cache availability.
optionsCheckCachedOptionsOptional cache check parameters.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<TorBoxResponse<CheckCached>>
The cache status data.
Exceptions
- ArgumentNullException
Thrown when
hashesis 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
requestCheckCachedRequestThe cache check request containing hashes and options.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<TorBoxResponse<CheckCached>>
The cache status data.
Exceptions
- ArgumentNullException
Thrown when
requestis 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
requestControlTorrentRequestThe control operation request.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<TorBoxResponse>
The API response.
Exceptions
- ArgumentNullException
Thrown when
requestis 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
requestCreateTorrentRequestThe torrent creation request containing the magnet URI or file bytes.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<TorBoxResponse<Torrent>>
The created torrent details.
Exceptions
- ArgumentNullException
Thrown when
requestis 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
requestEditTorrentRequestThe edit request containing the new property values.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<TorBoxResponse>
The API response.
Exceptions
- ArgumentNullException
Thrown when
requestis 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
torrentIdlongThe unique identifier of the torrent to export data for.
exportTypestringThe export type format, or null for the default format.
cancellationTokenCancellationTokenCancellation 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
optionsGetMyListOptionsOptional query parameters for filtering and pagination.
cancellationTokenCancellationTokenCancellation 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
hashstringThe info hash of the torrent.
optionsGetTorrentInfoOptionsOptional torrent info parameters.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<TorBoxResponse<TorrentInfo>>
The torrent metadata information.
Exceptions
- ArgumentNullException
Thrown when
hashis null.- ArgumentException
Thrown when
hashis 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
requestTorrentInfoRequestThe torrent info request containing the file bytes, magnet URI, hash, and options.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<TorBoxResponse<TorrentInfo>>
The torrent metadata information.
Exceptions
- ArgumentNullException
Thrown when
requestis 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
requestMagnetToFileRequestThe request containing the magnet link to convert.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<TorBoxResponse<string>>
The torrent file data as a string.
Exceptions
- ArgumentNullException
Thrown when
requestis 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
torrentIdlongThe unique identifier of the torrent to download.
optionsRequestDownloadOptionsOptional download request options.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<TorBoxResponse<string>>
The download URL as a string.
Exceptions
- TorBoxException
Thrown when the API returns an error.