Kavenegar 2.0.1

dotnet add package Kavenegar --version 2.0.1
                    
NuGet\Install-Package Kavenegar -Version 2.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Kavenegar" Version="2.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Kavenegar" Version="2.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Kavenegar" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Kavenegar --version 2.0.1
                    
#r "nuget: Kavenegar, 2.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Kavenegar@2.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Kavenegar&version=2.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Kavenegar&version=2.0.1
                    
Install as a Cake Tool

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

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). Contains Code and Message.
  • Kavenegar.Exceptions.HttpException: Raised when a network or HTTP connection problem occurs before reaching the API service.

Resources & Documentation

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last Updated
2.0.1 187 9/6/2026
1.2.5 20,733 12/24/2024
1.2.4 70,516 4/13/2020
1.1.5-alpha.1 193 12/24/2024
1.1.4 6,029 10/1/2018
1.1.2 5,611 7/2/2017

- 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.