Table of Contents

Class TorBoxClient

Namespace
TorBoxSDK
Assembly
TorBoxSDK.dll

Root entry point for the TorBox SDK.

public sealed class TorBoxClient : ITorBoxClient, IDisposable
Inheritance
TorBoxClient
Implements
Inherited Members

Remarks

TorBoxClient aggregates the three API-family clients (IMainApiClient, ISearchApiClient, IRelayApiClient) into a single injectable service. All sub-clients are instantiated internally and are not available through the DI container. Users must use ITorBoxClient to access all SDK functionality.

The client can be used standalone (via new TorBoxClient(apiKey)) or through dependency injection using AddTorBox(IServiceCollection, Action<TorBoxClientOptions>).

In standalone mode, the client owns its HttpClient instances and must be disposed when no longer needed (preferably with a using statement). In DI mode, the container manages the lifecycle and Dispose() is a no-op.

Constructors

TorBoxClient(Action<TorBoxClientOptions>)

Initializes a new standalone instance of the TorBoxClient class using a configuration delegate.

public TorBoxClient(Action<TorBoxClientOptions> configure)

Parameters

configure Action<TorBoxClientOptions>

A delegate to configure TorBoxClientOptions.

Exceptions

ArgumentNullException

Thrown when configure is null.

ArgumentException

Thrown when the configured ApiKey is null or empty.

TorBoxClient(IHttpClientFactory, IOptions<TorBoxClientOptions>)

Initializes a new instance of the TorBoxClient class using an IHttpClientFactory to create the required HTTP clients. This constructor is intended for DI usage.

[ActivatorUtilitiesConstructor]
public TorBoxClient(IHttpClientFactory httpClientFactory, IOptions<TorBoxClientOptions> options)

Parameters

httpClientFactory IHttpClientFactory

The HTTP client factory used to create named clients.

options IOptions<TorBoxClientOptions>

The SDK configuration options.

Exceptions

ArgumentNullException

Thrown when httpClientFactory or options is null.

TorBoxClient(string)

Initializes a new standalone instance of the TorBoxClient class using the specified API key and default options.

public TorBoxClient(string apiKey)

Parameters

apiKey string

The TorBox API key used for Bearer authentication.

Exceptions

ArgumentNullException

Thrown when apiKey is null.

ArgumentException

Thrown when apiKey is empty.

TorBoxClient(TorBoxClientOptions)

Initializes a new standalone instance of the TorBoxClient class using the specified options.

public TorBoxClient(TorBoxClientOptions options)

Parameters

options TorBoxClientOptions

The SDK configuration options.

Exceptions

ArgumentNullException

Thrown when options is null.

ArgumentException

Thrown when ApiKey is null or empty, or when a base URL is not a valid absolute URI.

Properties

Main

Gets the Main API client, which exposes resource clients for torrents, usenet, web downloads, user management, and more.

public IMainApiClient Main { get; }

Property Value

IMainApiClient

Relay

Gets the Relay API client for relay-based operations.

public IRelayApiClient Relay { get; }

Property Value

IRelayApiClient

Gets the Search API client for querying torrent and usenet indexers.

public ISearchApiClient Search { get; }

Property Value

ISearchApiClient

Methods

Dispose()

Releases the HTTP clients owned by this instance (standalone mode only). In DI mode, this method is a no-op because the container manages the HTTP client lifecycle.

public void Dispose()