Baileys.NET
1.2.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Baileys.NET --version 1.2.0
NuGet\Install-Package Baileys.NET -Version 1.2.0
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.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Baileys.NET" Version="1.2.0" />
<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.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Baileys.NET, 1.2.0"
#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.2.0
#: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.2.0
#tool nuget:?package=Baileys.NET&version=1.2.0
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
- Default Constants — WebSocket URL, noise-protocol constants, media HKDF key mappings, browser description presets, timing defaults
- Structured Logging —
ILoggerinterface +NullLoggerandConsoleLoggerimplementations - Dependency Injection —
AddBaileys(),AddBaileysWithFileStorage(),AddBaileysWithProvider<T>()helpers - Pluggable Session Storage —
IAuthStateProviderinterface with in-memory and file-based implementations
Quick Start
using Baileys.Types;
using Baileys.Utils;
using Baileys.WABinary;
using Baileys.Defaults;
using Baileys.Extensions;
// ── Dependency injection (Program.cs) ────────────────────────────────────────
builder.Services.AddBaileys(o => o.PhoneNumber = "15551234567");
// or persist to a JSON file:
builder.Services.AddBaileysWithFileStorage("creds.json", o => o.PhoneNumber = "15551234567");
// ── Credential initialisation ─────────────────────────────────────────────────
var creds = AuthUtils.InitAuthCreds();
Console.WriteLine($"Registration ID: {creds.RegistrationId}");
// ── JID utilities ─────────────────────────────────────────────────────────────
var jid = JidUtils.JidDecode("123456789@s.whatsapp.net");
var isGroup = JidUtils.IsJidGroup("120363000000001@g.us"); // true
// ── Crypto ────────────────────────────────────────────────────────────────────
var key = Crypto.RandomBytes(32);
var iv = Crypto.RandomBytes(12);
var ct = Crypto.AesEncryptGcm("Hello WhatsApp!"u8, key, iv, ReadOnlySpan<byte>.Empty);
var pt = Crypto.AesDecryptGcm(ct, key, iv, ReadOnlySpan<byte>.Empty);
// ── WABinary round-trip ───────────────────────────────────────────────────────
var node = new BinaryNode { Tag = "iq", Attrs = new() { ["type"] = "get" } };
var wire = WaBinaryEncoder.EncodeBinaryNode(node);
var decoded = await WaBinaryDecoder.DecodeBinaryNodeAsync(wire);
// ── Browser description ───────────────────────────────────────────────────────
var browser = Browsers.MacOs("Chrome"); // ["Mac OS", "Chrome", "14.4.1"]
Namespace Map
| Namespace | Contents |
|---|---|
Baileys.Types |
All domain types and enums |
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 |
Baileys.Extensions |
ServiceCollectionExtensions |
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
- Microsoft.Extensions.DependencyInjection.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.