Baileys.NET
1.9.1
dotnet add package Baileys.NET --version 1.9.1
NuGet\Install-Package Baileys.NET -Version 1.9.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="Baileys.NET" Version="1.9.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Baileys.NET" Version="1.9.1" />
<PackageReference Include="Baileys.NET" />
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 Baileys.NET --version 1.9.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Baileys.NET, 1.9.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 Baileys.NET@1.9.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=Baileys.NET&version=1.9.1
#tool nuget:?package=Baileys.NET&version=1.9.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Baileys — WhatsApp Web Library for .NET 10
A .NET 10 port of the Baileys TypeScript library for interacting with the WhatsApp Web API.
Installation
dotnet add package Baileys.NET
Or via the NuGet Package Manager:
Install-Package Baileys.NET
Documentation
Full documentation is available in the docs/ folder:
| Guide | Description |
|---|---|
| Getting Started | Installation, quick start, first session |
| Dependency Injection | ASP.NET Core / Worker Service integration |
| Session Storage | InMemory, File, and custom DB providers |
| Cryptography | AES-GCM/CBC/CTR, HMAC, HKDF, PBKDF2 |
| JID Utilities | Encode, decode, classify JIDs |
| Auth Utilities | Credential init, key generation |
| WABinary Codec | Binary node encoding / decoding |
| Types Reference | All WhatsApp domain types |
| Events Reference | Event payload types |
| Defaults & Constants | Protocol constants, browser presets |
Features
- Binary Protocol Codec — Encode and decode the WhatsApp binary node wire format (WABinary), including zlib decompression
- Cryptographic Utilities — AES-256-GCM/CBC/CTR, HMAC-SHA-256/512, SHA-256/MD5, HKDF, PBKDF2 — all via
System.Security.Cryptography(no third-party deps) - JID Utilities — Encode, decode, normalise, and classify JIDs (user, group, broadcast, newsletter, LID, hosted)
- Auth Utilities —
InitAuthCreds(), Curve25519 key-pair generation, signed pre-key generation - Noise Protocol Handler — Noise_XX_25519_AESGCM_SHA256 handshake state machine
- Complete Type Definitions — All WhatsApp types: Contact, Chat, GroupMetadata, Message, Call, Label, Newsletter, Business, Product, State, Event payloads
- Signal Key Store —
ISignalKeyStoreinterface with in-memory (InMemorySignalKeyStore) and directory-backed (DirectorySignalKeyStore) implementations; typed extension helpers for every Signal data category (pre-key, session, sender-key, app-state-sync, lid-mapping, device-list, tctoken, identity-key) - Full Authentication State —
AuthenticationStatebundlesAuthenticationCreds+ISignalKeyStoreexactly like the TypeScriptAuthenticationStatetype;LoadAuthStateAsync()extension builds one from anyIAuthStateProvider - Directory Auth Provider —
DirectoryAuthStateProviderstores credentials increds.jsonand Signal keys as individual files in one directory, mirroring the TypeScriptuseMultiFileAuthState(folder)integration pattern - Default Constants — WebSocket URL, noise-protocol constants, media HKDF key mappings, browser description presets, timing defaults
- Structured Logging —
ILoggerinterface +NullLoggerandConsoleLoggerimplementations - Dependency Injection —
AddBaileys(),AddBaileysWithFileStorage(),AddBaileysWithDirectoryStorage(),AddBaileysWithProvider<T>()helpers - Pluggable Session Storage —
IAuthStateProviderinterface with in-memory, file-based, and directory-based implementations - Automatic Session Initiation —
BaileysClientandBaileysClientHostedServiceautomatically manage the WebSocket connection, Noise handshake, and QR code lifecycle
Quick Start
using Baileys;
using Baileys.Types;
using Baileys.Utils;
using Baileys.Extensions;
// ── Dependency injection (Program.cs) ────────────────────────────────────────
// This will automatically initiate a session and print the QR code to the console
// when the application starts.
builder.Services.AddBaileysWithDirectoryStorage(
directory: "baileys_auth_info",
configure: o =>
{
o.PhoneNumber = "15551234567";
o.PrintQrInTerminal = true; // Default is true
});
// ── Manual Connection (optional) ────────────────────────────────────────────
// If you prefer manual control, you can inject BaileysClient:
public class MyService(BaileysClient client)
{
public async Task StartAsync()
{
// Subscribe to events
client.Ev.On<ConnectionUpdateEvent>("connection.update", update => {
if(update.Connection == WaConnectionState.Open) {
Console.WriteLine("Connected!");
}
});
await client.ConnectAsync();
}
}
Namespace Map
| Namespace | Contents |
|---|---|
Baileys |
BaileysClient |
Baileys.Types |
All domain types and enums, ISignalKeyStore, SignalDataTypes, AuthenticationState, SignalKeyStoreExtensions, TcToken |
Baileys.Utils |
Crypto, JidUtils, AuthUtils, Generics, NoiseHandler, ILogger |
Baileys.WABinary |
WaBinaryEncoder, WaBinaryDecoder, WaBinaryConstants |
Baileys.Defaults |
BaileysDefaults, Browsers |
Baileys.Options |
BaileysOptions |
Baileys.Session |
IAuthStateProvider, InMemoryAuthStateProvider, FileAuthStateProvider, DirectoryAuthStateProvider, InMemorySignalKeyStore, DirectorySignalKeyStore |
Baileys.Extensions |
ServiceCollectionExtensions, AuthStateExtensions, BaileysClientHostedService |
Baileys.Socket |
BaileysSocket |
Requirements
- .NET 10+
- Runtime NuGet dependencies:
Microsoft.Extensions.DependencyInjection.AbstractionsandMicrosoft.Extensions.Options
License
MIT — see LICENSE
| Product | Versions 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.
-
net10.0
- BouncyCastle.Cryptography (>= 2.6.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.4)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.4)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.4)
- Microsoft.Extensions.Options (>= 10.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.