TlsClient.Api
0.4.6
dotnet add package TlsClient.Api --version 0.4.6
NuGet\Install-Package TlsClient.Api -Version 0.4.6
<PackageReference Include="TlsClient.Api" Version="0.4.6" />
<PackageVersion Include="TlsClient.Api" Version="0.4.6" />
<PackageReference Include="TlsClient.Api" />
paket add TlsClient.Api --version 0.4.6
#r "nuget: TlsClient.Api, 0.4.6"
#:package TlsClient.Api@0.4.6
#addin nuget:?package=TlsClient.Api&version=0.4.6
#tool nuget:?package=TlsClient.Api&version=0.4.6
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 needTlsClient.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 anInvalidOperationExceptionis thrown (by design).- All options you set on the builder (headers, proxy, cookie jar, timeouts, etc.) are forwarded into
ApiTlsClientOptionsinsideWithApi(...).
🧯 Error Handling
- If serialization or service issues occur,
Response.Status = 0andBodycontains the error message. - If the error contains
"Client.Timeout exceeded", the client normalizes it to408 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.Tests → BodyTests 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 | Versions 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. |
-
.NETStandard 2.1
- TlsClient.Core (>= 0.4.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.