TlsClient.Api 0.4.6

dotnet add package TlsClient.Api --version 0.4.6
                    
NuGet\Install-Package TlsClient.Api -Version 0.4.6
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TlsClient.Api" Version="0.4.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TlsClient.Api" Version="0.4.6" />
                    
Directory.Packages.props
<PackageReference Include="TlsClient.Api" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TlsClient.Api --version 0.4.6
                    
#r "nuget: TlsClient.Api, 0.4.6"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TlsClient.Api@0.4.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TlsClient.Api&version=0.4.6
                    
Install as a Cake Addin
#tool nuget:?package=TlsClient.Api&version=0.4.6
                    
Install as a Cake Tool

TlsClient.Api

A .NET client for TlsClient.NET that connects to a remote TlsClient Service.

This package builds on top of TlsClient.Core models (Request, Response, TlsClientCookie, etc.), but handles transport via the remote API.


📦 Installation

dotnet add package TlsClient.Api

Unlike TlsClient.Native, you do not need TlsClient.Initialize(...) here. Simply provide the service base URL and an API key.


🚀 Quick Start

Minimal Example

using TlsClient.Api;
using TlsClient.Core.Models.Requests;

using var client = new ApiTlsClient(new Uri("http://127.0.0.1:8080"), "my-auth-key-1");

var response = client.Request(new Request {
    RequestUrl = "https://httpbin.io/get"
});

Console.WriteLine($"{(int)response.Status} {response.Status}");
Console.WriteLine(response.Body);

With Options

using TlsClient.Api;
using TlsClient.Core.Models.Entities;
using TlsClient.Core.Models.Requests;

var options = new ApiTlsClientOptions(
    TlsClientIdentifier.Chrome133,
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 OPR/117.0.0.0",
    new Uri("http://127.0.0.1:8080"),
    "my-auth-key-1"
);

using var client = new ApiTlsClient(options);

var response = await client.RequestAsync(new Request { RequestUrl = "https://example.com" });

🧱 API Interface

The public interface of ApiTlsClient:

public sealed class ApiTlsClient : BaseTlsClient, IAsyncDisposable
{
    public RestClient RestClient { get; }

    public ApiTlsClient(ApiTlsClientOptions options);
    public ApiTlsClient(Uri apiBaseUri, string apiKey);

    // Sync methods
    public override Response Request(Request request);
    public override GetCookiesFromSessionResponse AddCookies(string url, List<TlsClientCookie> cookies);
    public override DestroyResponse Destroy();
    public override GetCookiesFromSessionResponse GetCookies(string url);
    public override DestroyResponse DestroyAll();

    // Async methods
    public override Task<Response> RequestAsync(Request request, CancellationToken ct = default);
    public override Task<GetCookiesFromSessionResponse> AddCookiesAsync(string url, List<TlsClientCookie> cookies, CancellationToken ct = default);
    public override Task<DestroyResponse> DestroyAsync(CancellationToken ct = default);
    public override Task<GetCookiesFromSessionResponse> GetCookiesAsync(string url, CancellationToken ct = default);
    public override Task<DestroyResponse> DestroyAllAsync(CancellationToken ct = default);

    public override ValueTask DisposeAsync();
}

🧱 API Client — Builder Usage

Use the shared builder to configure common options, then switch to the API transport with WithApi(...) and call Build() to get an ApiTlsClient.

    // 1) Create client
    using var client = new TlsClientBuilder()
        .WithIdentifier(TlsClientIdentifier.Chrome133)
        .WithUserAgent("MyApp/1.0")
        .WithFollowRedirects()
        .WithTimeout(TimeSpan.FromSeconds(15))
        .WithDefaultCookieJar()
        .WithHeader("Accept-Language", "en-US,en;q=0.9")
        .WithProxyUrl("http://127.0.0.1:8086", isRotating: false);
        .WithApi(new Uri("http://127.0.0.1:8080"), "my-auth-key-1")
        .Build();

    // 2) Make a request
    var response = await client.RequestAsync(new Request
    {
        RequestUrl = "https://httpbin.io/get"
    });

    Console.WriteLine($"{(int)response.Status} {response.Status}");
    Console.WriteLine(response.Body);

Note:

  • You must call .WithApi(...) before .Build(); otherwise an InvalidOperationException is thrown (by design).
  • All options you set on the builder (headers, proxy, cookie jar, timeouts, etc.) are forwarded into ApiTlsClientOptions inside WithApi(...).

🧯 Error Handling

  • If serialization or service issues occur, Response.Status = 0 and Body contains the error message.
  • If the error contains "Client.Timeout exceeded", the client normalizes it to 408 RequestTimeout.
  • When using StreamOutputPath, make sure the file path is writable.

🔬 Learn More

This documentation focuses on the API interface and basic usage. For more detailed usage scenarios and real-world examples, check the test suite: TlsClient.Api.TestsBodyTests and CookieTests. These cover JSON requests, form-data, multipart uploads, streaming to files, and cookie management in depth.


📜 License

MIT — see the root LICENSE file.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.4.6 211 3/13/2026
0.4.5 102 3/13/2026
0.4.4 219 1/20/2026
0.4.3 271 9/8/2025
0.4.2 264 9/8/2025 0.4.2 is deprecated because it has critical bugs.
0.4.1 277 9/8/2025 0.4.1 is deprecated because it has critical bugs.
0.4.0 278 9/8/2025 0.4.0 is deprecated because it has critical bugs.