KaspiShopClient 0.1.0
dotnet add package KaspiShopClient --version 0.1.0
NuGet\Install-Package KaspiShopClient -Version 0.1.0
<PackageReference Include="KaspiShopClient" Version="0.1.0" />
<PackageVersion Include="KaspiShopClient" Version="0.1.0" />
<PackageReference Include="KaspiShopClient" />
paket add KaspiShopClient --version 0.1.0
#r "nuget: KaspiShopClient, 0.1.0"
#:package KaspiShopClient@0.1.0
#addin nuget:?package=KaspiShopClient&version=0.1.0
#tool nuget:?package=KaspiShopClient&version=0.1.0
KaspiShopClient
A .NET client library for interacting with the Kaspi.kz Shop API. This library provides easy access to product categories, attributes, and attribute values with built-in authentication and error handling.
Features
- 🔐 Automatic Authentication - Built-in token-based authentication
- 📝 Comprehensive Logging - Request/response logging with configurable levels
- 🛡️ Error Handling - Robust error handling and exception management
- ⚙️ Flexible Configuration - Multiple configuration options (direct, options pattern, appsettings.json)
- 📊 Strongly Typed - Full IntelliSense support with detailed XML documentation
- 🏗️ Dependency Injection - Native support for .NET dependency injection
Installation
Install the package via NuGet Package Manager:
dotnet add package KaspiShopClient
Or via Package Manager Console:
Install-Package KaspiShopClient
For Models/Contracts (KaspiShopClient.Contracts)
If you only need the contract models without the client functionality, you can install the KaspiShopClient.Contracts package separately:
dotnet add package KaspiShopClient.Contracts
Or via Package Manager Console:
Install-Package KaspiShopClient.Contracts
Quick Start
1. Basic Setup
using Microsoft.Extensions.DependencyInjection;
using KaspiShopClient;
// Register the client with dependency injection
services.AddKaspiShopClient("your-auth-token-here");
2. Using the Client
public class ProductService
{
private readonly IKaspiShopApi _kaspiApi;
public ProductService(IKaspiShopApi kaspiApi)
{
_kaspiApi = kaspiApi;
}
public async Task<List<ProductCategory>> GetCategoriesAsync()
{
return await _kaspiApi.GetProductCategoriesAsync();
}
public async Task<List<ProductAttribute>> GetAttributesAsync(string categoryCode)
{
return await _kaspiApi.GetProductAttributesAsync(categoryCode);
}
public async Task<List<ProductAttributeValue>> GetAttributeValuesAsync(
string categoryCode,
string attributeCode)
{
return await _kaspiApi.GetProductAttributeValuesAsync(categoryCode, attributeCode);
}
}
Configuration Options
Option 1: Direct Token
services.AddKaspiShopClient("your-auth-token-here");
Option 2: Configuration Object
services.AddKaspiShopClient(options =>
{
options.AuthToken = "your-auth-token-here";
options.BaseAddress = "https://kaspi.kz/shop/api/";
options.TimeoutSeconds = 60;
});
Option 3: appsettings.json
{
"KaspiShopClient": {
"AuthToken": "your-auth-token-here",
"BaseAddress": "https://kaspi.kz/shop/api/",
"TimeoutSeconds": 30
}
}
services.Configure<KaspiShopClientOptions>(configuration.GetSection("KaspiShopClient"));
services.AddKaspiShopClient();
API Reference
IKaspiShopApi
| Method | Description | Parameters |
|---|---|---|
GetProductCategoriesAsync() |
Get all product categories | None |
GetProductAttributesAsync(categoryCode) |
Get attributes for a category | categoryCode: Category identifier |
GetProductAttributeValuesAsync(categoryCode, attributeCode) |
Get possible values for an attribute | categoryCode: Category identifier<br>attributeCode: Attribute identifier |
Models
- ProductCategory: Represents a product category
- ProductAttribute: Represents a product attribute/characteristic
- ProductAttributeValue: Represents possible values for an attribute
Configuration Properties
| Property | Type | Default | Description |
|---|---|---|---|
AuthToken |
string? |
null |
Authentication token for API requests |
BaseAddress |
string |
"https://kaspi.kz/shop/api/" |
Base URL for the Kaspi Shop API |
TimeoutSeconds |
int |
30 |
HTTP request timeout in seconds |
Error Handling
The library includes comprehensive error handling:
- ApiException: Thrown for API-related errors (authentication, invalid parameters, etc.)
- HttpRequestException: Thrown for network-related errors
- TimeoutException: Thrown when requests exceed the configured timeout
All exceptions include detailed error information to help with debugging.
Logging
The library provides detailed logging for:
- Authentication token validation
- HTTP request/response details
- API errors and exceptions
- Performance metrics
Configure logging levels in your application to control verbosity.
Requirements
- .NET 9.0 (Preview)
- .NET 8.0 (LTS)
- .NET Standard 2.1
- Valid Kaspi.kz Shop API authentication token
Documentation
For detailed API documentation and examples, see:
License
This project is licensed under the MIT License.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
If you encounter any issues or have questions, please open an issue on GitHub.
| 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 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 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
- KaspiShopClient.Contracts (>= 0.1.0)
- Refit.HttpClientFactory (>= 8.0.0)
-
net8.0
- KaspiShopClient.Contracts (>= 0.1.0)
- Refit.HttpClientFactory (>= 8.0.0)
-
net9.0
- KaspiShopClient.Contracts (>= 0.1.0)
- Refit.HttpClientFactory (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release of KaspiShopClient with support for product categories, attributes, and attribute values API endpoints.