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
configureAction<TorBoxClientOptions>A delegate to configure TorBoxClientOptions.
Exceptions
- ArgumentNullException
Thrown when
configureis null.- ArgumentException
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
httpClientFactoryIHttpClientFactoryThe HTTP client factory used to create named clients.
optionsIOptions<TorBoxClientOptions>The SDK configuration options.
Exceptions
- ArgumentNullException
Thrown when
httpClientFactoryoroptionsis 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
apiKeystringThe TorBox API key used for Bearer authentication.
Exceptions
- ArgumentNullException
Thrown when
apiKeyis null.- ArgumentException
Thrown when
apiKeyis empty.
TorBoxClient(TorBoxClientOptions)
Initializes a new standalone instance of the TorBoxClient class using the specified options.
public TorBoxClient(TorBoxClientOptions options)
Parameters
optionsTorBoxClientOptionsThe SDK configuration options.
Exceptions
- ArgumentNullException
Thrown when
optionsis 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
Relay
Gets the Relay API client for relay-based operations.
public IRelayApiClient Relay { get; }
Property Value
Search
Gets the Search API client for querying torrent and usenet indexers.
public ISearchApiClient Search { get; }
Property Value
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()