WhatsAppWeb.NET 0.1.1

dotnet add package WhatsAppWeb.NET --version 0.1.1
                    
NuGet\Install-Package WhatsAppWeb.NET -Version 0.1.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="WhatsAppWeb.NET" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WhatsAppWeb.NET" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="WhatsAppWeb.NET" />
                    
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 WhatsAppWeb.NET --version 0.1.1
                    
#r "nuget: WhatsAppWeb.NET, 0.1.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 WhatsAppWeb.NET@0.1.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=WhatsAppWeb.NET&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=WhatsAppWeb.NET&version=0.1.1
                    
Install as a Cake Tool

WhatsAppWeb.NET

NuGet NuGet Downloads License

C# / .NET port of the whatsapp-web.js library (Node.js, by Pedro S. Lopez) for the .NET ecosystem.

The original project is a WhatsApp client library for Node.js that operates via WhatsApp Web using Puppeteer. This version reimplements the same approach in C#, replacing Puppeteer with Microsoft Playwright and exposing an idiomatic .NET API.

Getting Started

1. Configure environment variables

The tests interact with the real WhatsApp Web and require phone numbers for authentication and operations.

cp .env.example .env

Edit .env with your numbers (international format without +, e.g.: 5511999998888):

Variable Purpose
PHONE_NUMBER Your phone number. Receives the pairing code
TARGET_TEST_PHONE Target number for test operations (send messages, search chats, etc.)

2. Build

dotnet build WhatsAppWeb.slnx -v q

3. Run the tests

dotnet test WhatsAppWeb.slnx --no-build

4. Pair with WhatsApp

On startup, the test runner displays a pairing code in the output:

[xUnit.net 00:00:10.23] WhatsAppWebTests: [Warning] ClientHooks: === PAIRING CODE: XXXX-XXXX ===

On your phone, go to WhatsApp > Linked Devices > Link a Device > Enter code and type in the code. You have 1 minute before the timeout.

After pairing, the tests run automatically. The session is persisted on disk (.wwebjs_auth/), so subsequent runs will not require pairing again.

Library usage

using WhatsAppWebLib;

await using var client = new Client();

client.OnQrAsync(async _ =>
{
    var code = await client.RequestPairingCodeAsync("5511999999999");
    Console.WriteLine($"Enter on your phone: {code}");
});

client.OnReady(() => Console.WriteLine("Ready!"));

await client.InitializeAsync();

// Send message
var messageId = await client.Message.SendAsync("5511999999999", "Hello!");

// List chats
var chats = await client.Chat.GetChatsAsync();

For details on each feature, see the full documentation.

Features

Feature Status
Authentication via QR Code / Pairing Code OK
Send text messages OK
Reply, react, forward, edit, delete messages OK
Star/unstar messages OK
List and search chats OK
Archive, pin, mute chats OK
Mark chat as read OK
Simulate typing OK
Search messages OK
List contacts, check registration OK
Manage groups (participants, subject, description, invite) OK
Profile picture (URL and Base64) OK
Status and presence (online/offline) OK
Labels (WhatsApp Business) OK
Session persistence OK

Useful commands

# Run a specific scenario
dotnet test WhatsAppWeb.slnx --no-build --filter "DisplayName~chat list"

# List all tests
dotnet test WhatsAppWeb.slnx --no-build --list-tests

Troubleshooting

Problem Solution
Pairing code does not appear Check that "diagnosticMessages": true is set in xunit.runner.json
Authentication timeout Enter the code on your phone within 1 minute
Tests hang without output Always run dotnet build separately before dotnet test --no-build

Tech Stack

Layer Technology
Runtime .NET 10
Browser automation Microsoft Playwright
Testing xUnit v3 + ReqnRoll (Gherkin) + Shouldly

Disclaimer

This project is not affiliated, associated, authorized, endorsed, or in any way officially connected to WhatsApp or any of its subsidiaries or affiliates. There is no guarantee that you will not be blocked by using this method. WhatsApp does not allow bots or unofficial clients on its platform.

License

Based on whatsapp-web.js by Pedro S. Lopez, licensed under the Apache License 2.0.

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

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.1 149 1/30/2026
0.0.2 117 1/30/2026
0.0.1 109 1/30/2026