# Waha-net/waha-net: .NET C# Client Library for WhatsApp HTTP API (WAHA)

This repository profile is provided by osrepos.com, an open source repository discovery platform.

Source: osrepos.com
Repository profile: https://osrepos.com/repo/waha-net-waha-net
Generated for open source discovery and AI-assisted research.

Waha-net/waha-net is a .NET C# client library designed to simplify interaction with the WAHA (WhatsApp HTTP API). It enables developers to easily integrate WhatsApp services into their .NET applications, providing a streamlined way to manage chats and sessions.

GitHub: https://github.com/Waha-net/waha-net
OSRepos URL: https://osrepos.com/repo/waha-net-waha-net

## Summary

Waha-net/waha-net is a .NET C# client library designed to simplify interaction with the WAHA (WhatsApp HTTP API). It enables developers to easily integrate WhatsApp services into their .NET applications, providing a streamlined way to manage chats and sessions.

## Topics

- C#
- .NET
- WhatsApp
- API Client
- WAHA
- Messaging
- Library

## Repository Information

Last analyzed by OSRepos: Sun Oct 12 2025 10:16:34 GMT+0100 (Western European Summer Time)
Detail views: 3
GitHub clicks: 13

## Safety Notice

OSRepos shares public repositories for knowledge and discovery only. Review source code, dependencies, licenses, and security implications before running or installing anything.

## Content

## Introduction

Waha-net/waha-net is a .NET C# client library designed to simplify interaction with the WAHA (WhatsApp HTTP API). This library enables .NET developers to easily integrate WhatsApp services into their applications, providing an efficient way to manage chats and sessions. With Waha-net, you can build robust applications that communicate with WhatsApp through an HTTP API.

## Installation

To start using the Waha-net library in your .NET project, you can install it via NuGet.

Run the following command in your .NET project:

bash
dotnet add package Waha


Alternatively, you can use the NuGet Package Manager in Visual Studio to add the reference to the `Waha` package.

## Examples

This section demonstrates how to integrate Waha-net into your .NET projects. Before using the library, it's essential to have an instance of WAHA (WhatsApp HTTP API) running.

### Setting up WAHA Docker Container

First, ensure you have WAHA (WhatsApp HTTP API) running. Follow these steps to set it up as a Docker container:

**Prerequisite**: Ensure [Docker](https://docs.docker.com/get-docker/) is installed on your system.

bash
docker pull devlikeapro/waha


Run the container:

bash
docker run -it --rm -p 3000:3000/tcp --name waha devlikeapro/waha


After starting, WAHA will be accessible at `http://localhost:3000/`, where you can find the API documentation (Swagger).

### ASP.NET Core Integration

Here's a sample code snippet for an ASP.NET Core application that lists WhatsApp chats from the logged-in user:

csharp
using Waha;
using Microsoft.AspNetCore.Mvc; // Added for [FromHeader]

var builder = WebApplication.CreateBuilder(args);

// This method will look for "Waha" settings configuration section or connectionstring in your appsettings.json
// It also will use Waha default endpoint value ("localhost:3000") if can´t find a valid configuration
builder.AddWahaApiClient("Waha");

var app = builder.Build();
app.MapDefaultEndpoints();

app.MapGet("/chats", async (
  IWahaApiClient wahaApiClient, CancellationToken cancellationToken,
  [FromHeader] int limit = 5, [FromHeader] int offset = 0, [FromHeader] string sortBy = "", [FromHeader] string sortOrder = "") =>
{
  var sessions = await wahaApiClient.GetSessionsAsync(true, cancellationToken);
  var session = sessions.FirstOrDefault();
  if (session == null)
  {
      return Results.Json(new { Message = "No active session found." }, statusCode: StatusCodes.Status412PreconditionFailed);
  }
  var chats = await wahaApiClient.GetChatsAsync(session.Name, limit, offset, sortBy, sortOrder, cancellationToken);
  return Results.Ok(chats);
}).WithName("GetChats");

app.Run(); // Added app.Run() to make it a runnable example


### For Other .NET Applications

For .NET applications that are not ASP.NET Core, you can initialize the client as follows:

csharp
using Waha;
using System.Net.Http; // Added for HttpClient
using System.Threading; // Added for CancellationToken
using System.Linq; // Added for FirstOrDefault

var wahaApiClient = new WahaApiClient(new HttpClient() { BaseAddress = WahaSettings.Default.Endpoint });
var sessions = await wahaApiClient.GetSessionsAsync(true, CancellationToken.None); // Use CancellationToken.None for simplicity
var session = sessions.FirstOrDefault();
if (session != null)
{
    var chats = await wahaApiClient.GetChatsAsync(session.Name, 10, 0, "", "", CancellationToken.None); // Use CancellationToken.None
    // Process the chats as needed...
}


## Why Use Waha-net?

Waha-net significantly simplifies integration with the WhatsApp HTTP API (WAHA) in your .NET projects. By abstracting the complexities of API calls, it allows developers to focus on their application's business logic. The library is written in C#, leveraging the robust .NET ecosystem, and is open-source, encouraging community contributions and feedback. It's a powerful solution for any application needing to interact with WhatsApp programmatically.

## Links

*   **GitHub Repository**: [Waha-net/waha-net](https://github.com/Waha-net/waha-net)
*   **WAHA (WhatsApp HTTP API)**: [WAHA Project](https://github.com/devlikeapro/waha)
*   **Report Issues**: [GitHub Issues](https://github.com/Waha-net/waha-net/issues)