MxIO.ApiClient.Abstractions
2.0.150.1
dotnet add package MxIO.ApiClient.Abstractions --version 2.0.150.1
NuGet\Install-Package MxIO.ApiClient.Abstractions -Version 2.0.150.1
<PackageReference Include="MxIO.ApiClient.Abstractions" Version="2.0.150.1" />
<PackageVersion Include="MxIO.ApiClient.Abstractions" Version="2.0.150.1" />
<PackageReference Include="MxIO.ApiClient.Abstractions" />
paket add MxIO.ApiClient.Abstractions --version 2.0.150.1
#r "nuget: MxIO.ApiClient.Abstractions, 2.0.150.1"
#:package MxIO.ApiClient.Abstractions@2.0.150.1
#addin nuget:?package=MxIO.ApiClient.Abstractions&version=2.0.150.1
#tool nuget:?package=MxIO.ApiClient.Abstractions&version=2.0.150.1
MxIO.ApiClient.Abstractions
This library provides common models and interfaces for standardized API response handling, including pagination, filtering, and error management.
Installation
dotnet add package MxIO.ApiClient.Abstractions
Features
- Standardized API response models
- Common collection models for result sets
- Consistent error model structure
- Pagination support with metadata
- OData-like filtering options
Core Models
ApiResponse<T>
The ApiResponse<T>
class is a wrapper for API responses that includes:
public class ApiResponse<T>
{
public HttpStatusCode StatusCode { get; set; }
public T? Data { get; set; }
public ApiError[]? Errors { get; set; }
public ApiPagination? Pagination { get; set; }
public Dictionary<string, string>? Metadata { get; set; }
// Helper properties
public bool IsSuccess => (int)StatusCode >= 200 && (int)StatusCode < 300;
public bool IsNotFound => StatusCode == HttpStatusCode.NotFound;
public bool IsConflict => StatusCode == HttpStatusCode.Conflict;
public bool IsBadRequest => StatusCode == HttpStatusCode.BadRequest;
}
ApiError
The ApiError
class provides a standardized format for API errors:
public class ApiError
{
public string Code { get; set; } = string.Empty;
public string Message { get; set; } = string.Empty;
public string? Target { get; set; }
public ApiError[]? Details { get; set; }
}
ApiPagination
The ApiPagination
class provides standardized pagination information:
public class ApiPagination
{
public int TotalCount { get; set; }
public int FilteredCount { get; set; }
public int Skip { get; set; }
public int Top { get; set; }
public bool HasMore { get; set; }
}
CollectionModel<T>
The CollectionModel<T>
class provides a standardized container for collections of resources:
public class CollectionModel<T>
{
public List<T> Items { get; set; } = new List<T>();
}
FilterOptions
The FilterOptions
class provides standardized options for filtering API responses:
public class FilterOptions
{
public string? FilterExpression { get; set; }
public string[]? Select { get; set; }
public string[]? Expand { get; set; }
public string? OrderBy { get; set; }
public int Skip { get; set; }
public int Top { get; set; }
public bool Count { get; set; }
}
HttpResponseWrapper<T>
The HttpResponseWrapper<T>
class wraps API responses with HTTP-specific information:
public class HttpResponseWrapper<T>
{
public ApiResponse<T>? Result { get; set; }
public HttpStatusCode StatusCode { get; set; }
public string? Content { get; set; }
// Helper properties
public bool IsSuccess { get; }
public bool IsNotFound { get; }
public bool IsConflict { get; }
public bool IsBadRequest { get; }
}
Usage Examples
Creating API Responses
// Success response with data
var successResponse = new ApiResponse<User>
{
StatusCode = HttpStatusCode.OK,
Data = user
};
// Error response
var errorResponse = new ApiResponse<User>
{
StatusCode = HttpStatusCode.BadRequest,
Errors = new[]
{
new ApiError
{
Code = "InvalidUsername",
Message = "Username is invalid",
Target = "username"
}
}
};
// Collection response with pagination
var collectionResponse = new ApiResponse<CollectionModel<User>>
{
StatusCode = HttpStatusCode.OK,
Data = new CollectionModel<User>
{
Items = users
},
Pagination = new ApiPagination
{
TotalCount = 100,
FilteredCount = 10,
Skip = 0,
Top = 10,
HasMore = true
}
};
Working with Filter Options
// Create filter options for an API request
var filter = new FilterOptions
{
FilterExpression = "username eq 'john' and active eq true",
OrderBy = "created desc",
Skip = 0,
Top = 20,
Select = new[] { "username", "email", "firstName", "lastName" },
Expand = new[] { "roles", "permissions" }
};
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 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. |
-
net9.0
- Newtonsoft.Json (>= 13.0.3)
NuGet packages (7)
Showing the top 5 NuGet packages that depend on MxIO.ApiClient.Abstractions:
Package | Downloads |
---|---|
MX.GeoLocation.GeoLocationApi.Client
This package provides a web service client to query the geolocation service. |
|
XtremeIdiots.Portal.RepositoryApi.Abstractions
Abstractions for the XtremeIdiots Portal Repository API. |
|
XtremeIdiots.Portal.RepositoryApiClient
Client for the XtremeIdiots Portal Repository API. |
|
XtremeIdiots.Portal.ServersApi.Abstractions
Abstractions for the XtremeIdiots Portal Servers API. |
|
MxIO.ApiClient
An abstractions library containing common API client functionality for .NET 7. Contains common interfaces, extensions and models for API clients. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
2.0.150.1 | 354 | 6/30/2025 |
2.0.149.1 | 193 | 6/25/2025 |
1.1.147.1 | 2,438 | 6/23/2025 |
1.1.146.1 | 916 | 6/16/2025 |
1.1.145.1 | 365 | 6/9/2025 |
1.1.144.1 | 241 | 6/2/2025 |
1.1.143.1 | 185 | 5/26/2025 |
1.1.142.1 | 198 | 5/19/2025 |
1.1.141.1 | 265 | 5/12/2025 |
1.1.140.1 | 439 | 5/5/2025 |
1.1.139.1 | 750 | 4/28/2025 |
1.1.138.1 | 499 | 4/26/2025 |
1.1.137.1 | 185 | 4/25/2025 |
1.1.136.1 | 807 | 4/23/2025 |
1.1.135.1 | 329 | 4/21/2025 |
1.1.134.1 | 201 | 4/19/2025 |
1.1.133.1 | 121 | 4/19/2025 |
1.1.132.1 | 115 | 4/19/2025 |
1.1.131.1 | 144 | 4/19/2025 |
1.1.130.1 | 498 | 4/14/2025 |
1.1.129.1 | 675 | 4/7/2025 |
1.1.128.1 | 1,090 | 3/31/2025 |
1.1.127.1 | 1,460 | 3/24/2025 |
1.1.126.1 | 903 | 3/17/2025 |
1.1.125.1 | 1,148 | 3/16/2025 |
1.1.124.1 | 585 | 3/10/2025 |
1.1.123.1 | 719 | 3/3/2025 |
1.1.122.1 | 976 | 2/24/2025 |
1.1.115.1 | 2,130 | 1/6/2025 |
1.1.114.1 | 826 | 12/31/2024 |
1.1.113.1 | 865 | 12/30/2024 |
1.1.112.1 | 819 | 12/23/2024 |
1.1.111.1 | 847 | 12/16/2024 |
1.1.110.1 | 529 | 12/9/2024 |
1.1.109.1 | 409 | 12/2/2024 |
1.1.108.1 | 651 | 11/25/2024 |
1.1.107.1 | 828 | 11/18/2024 |
1.1.106.1 | 823 | 11/15/2024 |
1.1.105.1 | 985 | 11/11/2024 |
1.1.104.1 | 915 | 11/4/2024 |
1.1.103.1 | 791 | 10/28/2024 |
1.1.102.1 | 408 | 10/21/2024 |
1.1.101.1 | 1,121 | 10/14/2024 |
1.1.100.1 | 1,407 | 10/7/2024 |
1.1.99.1 | 1,054 | 9/30/2024 |
1.1.98.1 | 825 | 9/23/2024 |
1.1.97.1 | 1,054 | 9/17/2024 |
1.1.92.1 | 1,174 | 8/19/2024 |
1.1.91.1 | 949 | 8/12/2024 |
1.1.90.1 | 821 | 8/5/2024 |
1.1.89.1 | 683 | 7/29/2024 |
1.1.88.1 | 578 | 7/23/2024 |
1.1.87.1 | 731 | 7/22/2024 |
1.1.86.1 | 494 | 7/15/2024 |
1.1.85.1 | 802 | 7/8/2024 |
1.1.84.1 | 952 | 7/1/2024 |
1.1.83.1 | 1,873 | 6/24/2024 |
1.1.82.1 | 792 | 6/17/2024 |
1.1.81.1 | 1,285 | 6/10/2024 |
1.1.80.1 | 971 | 6/3/2024 |
1.1.79.1 | 964 | 5/27/2024 |
1.1.78.1 | 899 | 5/20/2024 |
1.1.77.1 | 869 | 5/13/2024 |
1.1.76.1 | 1,045 | 5/6/2024 |
1.1.75.1 | 1,607 | 4/29/2024 |
1.1.74.1 | 313 | 4/22/2024 |
1.1.73.1 | 341 | 4/15/2024 |
1.1.72.1 | 915 | 4/8/2024 |
1.1.71.1 | 398 | 4/1/2024 |
1.1.70.1 | 1,120 | 3/25/2024 |
1.1.69.1 | 272 | 3/18/2024 |
1.1.68.1 | 254 | 3/11/2024 |
1.1.67.1 | 853 | 3/4/2024 |
1.1.66.1 | 282 | 2/26/2024 |
1.1.65.1 | 299 | 2/19/2024 |
1.1.64.1 | 360 | 2/12/2024 |
1.1.63.1 | 354 | 2/7/2024 |
1.1.62.1 | 1,200 | 2/7/2024 |
1.1.61.1 | 935 | 2/6/2024 |
1.1.60.1 | 307 | 2/6/2024 |
1.1.59.1 | 462 | 2/5/2024 |
1.1.58.1 | 410 | 1/29/2024 |
1.1.57.1 | 420 | 1/22/2024 |
1.1.56.1 | 403 | 1/15/2024 |
1.1.55.1 | 471 | 1/8/2024 |
1.1.54.1 | 1,908 | 1/1/2024 |
1.1.53.1 | 613 | 12/25/2023 |
1.1.52.1 | 1,289 | 12/18/2023 |
1.1.51.1 | 494 | 12/11/2023 |
1.1.50.1 | 3,127 | 12/4/2023 |
1.1.49.1 | 2,154 | 11/27/2023 |
1.1.48.1 | 899 | 11/20/2023 |
1.1.47.1 | 2,653 | 11/13/2023 |
1.1.46.1 | 564 | 11/11/2023 |
1.1.45.1 | 1,172 | 11/11/2023 |
1.1.44.1 | 417 | 11/11/2023 |
1.1.43.1 | 365 | 11/11/2023 |
1.1.42.1 | 402 | 11/11/2023 |
1.1.41.1 | 394 | 11/11/2023 |
1.1.40.1 | 408 | 11/11/2023 |
1.1.39.1 | 976 | 11/9/2023 |
1.1.38.1 | 410 | 11/9/2023 |
1.1.37.1 | 411 | 11/9/2023 |
1.1.36.1 | 418 | 11/9/2023 |
1.1.35.1 | 1,274 | 11/6/2023 |
1.1.34.1 | 1,771 | 10/30/2023 |
1.1.33.1 | 805 | 10/27/2023 |
1.1.32.1 | 1,209 | 10/23/2023 |
1.1.31.1 | 1,142 | 10/21/2023 |
1.1.30.1 | 513 | 10/21/2023 |
1.1.29.1 | 414 | 10/21/2023 |
1.1.28.1 | 441 | 10/21/2023 |
1.1.27.1 | 442 | 10/20/2023 |
1.1.26.1 | 483 | 10/20/2023 |
1.1.25.1 | 496 | 10/20/2023 |
1.1.24.1 | 447 | 10/20/2023 |
1.0.23.1 | 444 | 10/20/2023 |