Kavenegar 2.0.1
dotnet add package Kavenegar --version 2.0.1
NuGet\Install-Package Kavenegar -Version 2.0.1
<PackageReference Include="Kavenegar" Version="2.0.1" />
<PackageVersion Include="Kavenegar" Version="2.0.1" />
<PackageReference Include="Kavenegar" />
paket add Kavenegar --version 2.0.1
#r "nuget: Kavenegar, 2.0.1"
#:package Kavenegar@2.0.1
#addin nuget:?package=Kavenegar&version=2.0.1
#tool nuget:?package=Kavenegar&version=2.0.1
Kavenegar C# / .NET SDK
The official .NET client library for the Kavenegar REST API. Easily send SMS, bulk messages, voice calls, and verification tokens (OTP) in your .NET applications.
Supported Frameworks
| Target | Compatibility | Async Support |
|---|---|---|
| .NET | 10.0, 8.0, 6.0 | Yes (async/await) |
| .NET Standard | 2.0+ (.NET Core 2.0+, .NET 5+) | Yes (async/await) |
| .NET Framework | 3.5+ | Synchronous |
Installation
.NET CLI
dotnet add package Kavenegar
Package Manager (Visual Studio Console)
Install-Package Kavenegar
PackageReference
<PackageReference Include="Kavenegar" Version="2.0.1" />
Quickstart
1. Send SMS (Asynchronous — Recommended)
For modern .NET applications (.NET 6 / 8 / 10):
using System;
using System.Threading.Tasks;
using Kavenegar;
using Kavenegar.Exceptions;
class Program
{
static async Task Main(string[] args)
{
var api = new KavenegarApi("YOUR_API_KEY");
try
{
var result = await api.SendAsync("1000100055", "09120000000", "Hello from Kavenegar!");
Console.WriteLine($"Message sent successfully! ID: {result.Messageid}");
}
catch (ApiException ex)
{
// API returned a non-success status code
Console.WriteLine($"API Error [{ex.Code}]: {ex.Message}");
}
catch (HttpException ex)
{
// Network / connectivity issue
Console.WriteLine($"HTTP Error [{ex.Code}]: {ex.Message}");
}
}
}
2. Send SMS (Synchronous)
Compatible with all frameworks, including legacy .NET Framework 3.5:
using System;
using Kavenegar;
var api = new KavenegarApi("YOUR_API_KEY");
var result = api.Send("1000100055", "09120000000", "Hello from Kavenegar!");
Console.WriteLine($"Message ID: {result.Messageid}, Status: {result.Status}");
3. Send Verification Code (Lookup / OTP)
Send instant OTP tokens using predefined Kavenegar templates:
// Async (Recommended)
var result = await api.VerifyLookupAsync(
receptor: "09120000000",
token: "12345",
template: "verify"
);
Console.WriteLine($"Verification SMS sent. ID: {result.Messageid}");
ASP.NET Core & Dependency Injection
Integrate cleanly with ASP.NET Core using AddHttpClient to benefit from automatic connection pooling and HTTP lifecycle management:
1. Configure in appsettings.json
{
"Kavenegar": {
"ApiKey": "YOUR_API_KEY"
}
}
2. Register Service in Program.cs
using Kavenegar;
builder.Services.AddHttpClient<IKavenegarApi, KavenegarApi>((httpClient, sp) =>
{
var options = sp.GetRequiredService<IConfiguration>()
.GetSection("Kavenegar")
.Get<KavenegarOptions>();
return new KavenegarApi(options, httpClient);
});
3. Inject in Controllers or Services
public class AuthService
{
private readonly IKavenegarApi _kavenegar;
public AuthService(IKavenegarApi kavenegar)
{
_kavenegar = kavenegar;
}
public async Task SendLoginOtp(string phoneNumber, string code)
{
await _kavenegar.VerifyLookupAsync(phoneNumber, code, "login-otp");
}
}
Error Handling
The SDK provides specific exception types for precise error handling:
Kavenegar.Exceptions.ApiException: Raised when the Kavenegar API rejects a request (e.g. invalid sender number, insufficient balance, invalid receptor). ContainsCodeandMessage.Kavenegar.Exceptions.HttpException: Raised when a network or HTTP connection problem occurs before reaching the API service.
Resources & Documentation
- Official Website: kavenegar.com
- REST API Documentation: kavenegar.com/rest.html
- GitHub Repository: github.com/kavenegar/kavenegar-dotnet
- Report Issues: github.com/kavenegar/kavenegar-dotnet/issues
- Support Email: support@kavenegar.com
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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 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 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net35 is compatible. net40 was computed. net403 was computed. net45 was computed. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 3.5
- Newtonsoft.Json (>= 12.0.3)
-
.NETStandard 2.0
- Newtonsoft.Json (>= 12.0.3)
-
net10.0
- Newtonsoft.Json (>= 12.0.3)
-
net6.0
- Newtonsoft.Json (>= 12.0.3)
-
net8.0
- Newtonsoft.Json (>= 12.0.3)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on Kavenegar:
| Package | Downloads |
|---|---|
|
PsToolkitBK
PsToolkitBK |
|
|
Avinex.SharedLibrary
Package Description |
|
|
KaveNegarApi
Package Description |
|
|
KamiSama.ExternalServices.Sms.Kavenegar
Scoped Kavenegar SMS provider registration and configuration for KamiSama SMS services. The current sender has an inverted validation defect that rejects a configured API key before sending. |
|
|
Dorbit.Framework
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
- Multi-target framework support (.NET 10, .NET 8, .NET 6, .NET Standard 2.0, .NET Framework 3.5).
- Full asynchronous API support (SendAsync, VerifyLookupAsync, etc.) with connection pooling.
- ASP.NET Core Dependency Injection integration (AddHttpClient<IKavenegarApi, KavenegarApi>).
- Enhanced exception handling with ApiException and HttpException.
- Modernized package documentation and NuGet README.
- Enforced SSL/TLS secure communication endpoints.