Pitasoft.Client
7.0.3
See the version list below for details.
dotnet add package Pitasoft.Client --version 7.0.3
NuGet\Install-Package Pitasoft.Client -Version 7.0.3
<PackageReference Include="Pitasoft.Client" Version="7.0.3" />
<PackageVersion Include="Pitasoft.Client" Version="7.0.3" />
<PackageReference Include="Pitasoft.Client" />
paket add Pitasoft.Client --version 7.0.3
#r "nuget: Pitasoft.Client, 7.0.3"
#:package Pitasoft.Client@7.0.3
#addin nuget:?package=Pitasoft.Client&version=7.0.3
#tool nuget:?package=Pitasoft.Client&version=7.0.3
Pitasoft.Client
English
Pitasoft.Client is a .NET library designed to simplify the consumption of RESTful services. It provides a robust base class and helpers to handle HTTP requests, JSON serialization, and common API patterns.
Features
- Base REST Service:
RestServiceBaseprovides methods for GET, POST, PUT, and DELETE operations, including batch processing support. - Modern HttpClient Management: Full support for
IHttpClientFactoryto ensure efficient connection management, socket pooling, and seamless integration with Dependency Injection. - Result Handling: Integrated with
Pitasoft.ResultandPitasoft.Errorfor consistent and expressive response handling. - Query Helpers: Utilities to easily and safely manage query strings in URIs.
- Flexible Configuration: Multiple constructors to support custom
HttpClient,IHttpClientFactory,Base URI, andJsonSerializerOptions.
Installation
Install via NuGet:
dotnet add package Pitasoft.Client
Basic Usage
1. Define your Service
Inherit from RestServiceBase to create your API client.
public class MyApiService : RestServiceBase
{
// Recommended: Use IHttpClientFactory
public MyApiService(IHttpClientFactory factory)
: base(factory, nameof(MyApiService)) { }
public async Task<ResultEntity<MyData>> GetDataAsync(int id)
{
return await GetAsync<MyData>($"api/data/{id}");
}
public async Task<ResultEntities<MyData>> GetAllDataAsync(string filter)
{
// Use QueryHelpers to build the URI safely
var uri = QueryHelpers.AddQueryString("api/data", "filter", filter);
return await GetsAsync<MyData>(uri);
}
}
2. Register in Dependency Injection
In your Program.cs or Startup.cs:
builder.Services.AddHttpClient(nameof(MyApiService), client =>
{
client.BaseAddress = new Uri("https://api.example.com/");
});
builder.Services.AddScoped<MyApiService>();
3. Other Initialization Options
You can also initialize the service directly without DI (e.g., in legacy code or simple tools):
// Using a Base URI string
var service = new MyApiService("https://api.example.com/");
// Using an existing HttpClient
var client = new HttpClient { BaseAddress = new Uri("https://api.example.com/") };
var serviceFromClient = new MyApiService(client);
Castellano
Pitasoft.Client es una librería .NET diseñada para simplificar el consumo de servicios RESTful. Proporciona una clase base robusta y utilidades para manejar peticiones HTTP, serialización JSON y patrones comunes de API, siguiendo las mejores prácticas de .NET.
Características
- Servicio REST Base:
RestServiceBaseproporciona métodos para operaciones GET, POST, PUT y DELETE, incluyendo soporte para procesamiento por lotes (batch). - Gestión Moderna de HttpClient: Soporte completo para
IHttpClientFactorypara asegurar una gestión eficiente de conexiones, pooling de sockets y una integración fluida con Inyección de Dependencias. - Manejo de Resultados: Integrado con
Pitasoft.ResultyPitasoft.Errorpara un manejo de respuestas consistente y expresivo. - Helpers de Consulta: Utilidades para gestionar de forma fácil y segura cadenas de consulta (query strings) en URIs.
- Configuración Flexible: Múltiples constructores para soportar
HttpClientpersonalizado,IHttpClientFactory,URI baseyJsonSerializerOptions.
Instalación
Instalar a través de NuGet:
dotnet add package Pitasoft.Client
Uso Básico
1. Define tu Servicio
Hereda de RestServiceBase para crear tu cliente de API.
public class MyApiService : RestServiceBase
{
// Recomendado: Usar IHttpClientFactory
public MyApiService(IHttpClientFactory factory)
: base(factory, nameof(MyApiService)) { }
public async Task<ResultEntity<MyData>> GetDataAsync(int id)
{
return await GetAsync<MyData>($"api/data/{id}");
}
public async Task<ResultEntities<MyData>> GetAllDataAsync(string filter)
{
// Usa QueryHelpers para construir la URI de forma segura
var uri = QueryHelpers.AddQueryString("api/data", "filter", filter);
return await GetsAsync<MyData>(uri);
}
}
2. Registro en Inyección de Dependencias
En tu Program.cs o Startup.cs:
builder.Services.AddHttpClient(nameof(MyApiService), client =>
{
client.BaseAddress = new Uri("https://api.example.com/");
});
builder.Services.AddScoped<MyApiService>();
3. Otras Opciones de Inicialización
También puedes inicializar el servicio directamente sin DI (por ejemplo, en código legado o herramientas simples):
// Usando una cadena de URI Base
var service = new MyApiService("https://api.example.com/");
// Usando un HttpClient existente
var client = new HttpClient { BaseAddress = new Uri("https://api.example.com/") };
var serviceDesdeClient = new MyApiService(client);
License
See LICENCE.txt for more details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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 is compatible. 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 is compatible. 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. |
-
net10.0
- Microsoft.Extensions.Http (>= 10.0.3)
- Pitasoft.Result (>= 7.0.2)
-
net8.0
- Microsoft.Extensions.Http (>= 10.0.3)
- Pitasoft.Result (>= 7.0.2)
-
net9.0
- Microsoft.Extensions.Http (>= 10.0.3)
- Pitasoft.Result (>= 7.0.2)
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 |
|---|---|---|
| 8.1.2 | 134 | 4/17/2026 |
| 8.1.1 | 147 | 3/26/2026 |
| 8.0.1 | 134 | 3/24/2026 |
| 7.0.7 | 137 | 3/20/2026 |
| 7.0.6 | 138 | 3/13/2026 |
| 7.0.5 | 144 | 3/2/2026 |
| 7.0.4 | 137 | 2/25/2026 |
| 7.0.3 | 145 | 2/12/2026 |
| 7.0.2 | 155 | 1/26/2026 |
| 7.0.1 | 160 | 1/26/2026 |
| 6.5.5 | 359 | 5/27/2025 |
| 6.5.4 | 338 | 5/27/2025 |
| 6.5.3 | 328 | 5/25/2025 |
| 6.5.2 | 342 | 5/25/2025 |
| 6.5.1 | 290 | 5/23/2025 |
| 6.5.0 | 341 | 5/19/2025 |
| 6.0.0 | 372 | 8/21/2024 |
| 5.2.2 | 377 | 5/17/2024 |
| 5.2.1 | 342 | 5/17/2024 |
| 5.2.0 | 455 | 11/20/2023 |