{"name":"Waha-net/waha-net: .NET C# Client Library for WhatsApp HTTP API (WAHA)","description":"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","url":"https://osrepos.com/repo/waha-net-waha-net","source":"osrepos.com","sourceDescription":"This repository profile is provided by osrepos.com, an open source repository discovery platform.","repositoryProfile":"https://osrepos.com/repo/waha-net-waha-net","generatedFor":"open source discovery and AI-assisted research","markdown":"https://osrepos.com/repo/waha-net-waha-net.md","json":"https://osrepos.com/repo/waha-net-waha-net.json","topics":["C#",".NET","WhatsApp","API Client","WAHA","Messaging","Library"],"keywords":["C#",".NET","WhatsApp","API Client","WAHA","Messaging","Library"],"stars":null,"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.","content":"## Introduction\n\nWaha-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.\n\n## Installation\n\nTo start using the Waha-net library in your .NET project, you can install it via NuGet.\n\nRun the following command in your .NET project:\n\nbash\ndotnet add package Waha\n\n\nAlternatively, you can use the NuGet Package Manager in Visual Studio to add the reference to the `Waha` package.\n\n## Examples\n\nThis 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.\n\n### Setting up WAHA Docker Container\n\nFirst, ensure you have WAHA (WhatsApp HTTP API) running. Follow these steps to set it up as a Docker container:\n\n**Prerequisite**: Ensure [Docker](https://docs.docker.com/get-docker/) is installed on your system.\n\nbash\ndocker pull devlikeapro/waha\n\n\nRun the container:\n\nbash\ndocker run -it --rm -p 3000:3000/tcp --name waha devlikeapro/waha\n\n\nAfter starting, WAHA will be accessible at `http://localhost:3000/`, where you can find the API documentation (Swagger).\n\n### ASP.NET Core Integration\n\nHere's a sample code snippet for an ASP.NET Core application that lists WhatsApp chats from the logged-in user:\n\ncsharp\nusing Waha;\nusing Microsoft.AspNetCore.Mvc; // Added for [FromHeader]\n\nvar builder = WebApplication.CreateBuilder(args);\n\n// This method will look for \"Waha\" settings configuration section or connectionstring in your appsettings.json\n// It also will use Waha default endpoint value (\"localhost:3000\") if can´t find a valid configuration\nbuilder.AddWahaApiClient(\"Waha\");\n\nvar app = builder.Build();\napp.MapDefaultEndpoints();\n\napp.MapGet(\"/chats\", async (\n  IWahaApiClient wahaApiClient, CancellationToken cancellationToken,\n  [FromHeader] int limit = 5, [FromHeader] int offset = 0, [FromHeader] string sortBy = \"\", [FromHeader] string sortOrder = \"\") =>\n{\n  var sessions = await wahaApiClient.GetSessionsAsync(true, cancellationToken);\n  var session = sessions.FirstOrDefault();\n  if (session == null)\n  {\n      return Results.Json(new { Message = \"No active session found.\" }, statusCode: StatusCodes.Status412PreconditionFailed);\n  }\n  var chats = await wahaApiClient.GetChatsAsync(session.Name, limit, offset, sortBy, sortOrder, cancellationToken);\n  return Results.Ok(chats);\n}).WithName(\"GetChats\");\n\napp.Run(); // Added app.Run() to make it a runnable example\n\n\n### For Other .NET Applications\n\nFor .NET applications that are not ASP.NET Core, you can initialize the client as follows:\n\ncsharp\nusing Waha;\nusing System.Net.Http; // Added for HttpClient\nusing System.Threading; // Added for CancellationToken\nusing System.Linq; // Added for FirstOrDefault\n\nvar wahaApiClient = new WahaApiClient(new HttpClient() { BaseAddress = WahaSettings.Default.Endpoint });\nvar sessions = await wahaApiClient.GetSessionsAsync(true, CancellationToken.None); // Use CancellationToken.None for simplicity\nvar session = sessions.FirstOrDefault();\nif (session != null)\n{\n    var chats = await wahaApiClient.GetChatsAsync(session.Name, 10, 0, \"\", \"\", CancellationToken.None); // Use CancellationToken.None\n    // Process the chats as needed...\n}\n\n\n## Why Use Waha-net?\n\nWaha-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.\n\n## Links\n\n*   **GitHub Repository**: [Waha-net/waha-net](https://github.com/Waha-net/waha-net)\n*   **WAHA (WhatsApp HTTP API)**: [WAHA Project](https://github.com/devlikeapro/waha)\n*   **Report Issues**: [GitHub Issues](https://github.com/Waha-net/waha-net/issues)","metrics":{"detailViews":3,"githubClicks":13},"dates":{"published":null,"modified":"2025-10-12T09:16:34.000Z"}}