@neelegirly/wa-api
v1.8.1
Published
Neelegirly multi-session wrapper API for @neelegirly/baileys (WhatsApp Web)
Maintainers
Readme
💌 @neelegirly/wa-api 💌
Multi-Session WhatsApp – jetzt mit echtem Lifecycle-Management
QR · Pairing · Pause/Resume · PM2-Ready · Update Notify
Installation · Quickstart · Lifecycle · Storage · API · Release Notes
✨ Was ist @neelegirly/wa-api?
@neelegirly/wa-api ist die komfortable Multi-Session-Schicht über @neelegirly/baileys. Der Wrapper nimmt dir den nervigen Teil ab: Session-Lifecycle, Credential-Handling, QR-/Pairing-Callbacks, Update-Status und PM2-freundliches Wiederanlaufen nach Neustarts.
Highlights auf einen Blick
| Feature | Beschreibung | Status |
|---------|--------------|--------|
| 🔀 Managed Multi-Session | Mehrere Sessions parallel inklusive Registry und Offline-Sicht | ✅ |
| ⏯️ Lifecycle API | start, pause, stop, resume, delete pro Session | ✅ |
| 💾 Credential-Migration | Standard ist jetzt _neelegirly, Legacy _credentials_neelegirly und _credentials bleiben kompatibel | ✅ |
| 🧠 PM2 Ready | desiredState, autoStart und loadSessionsFromStorage() für Warm-Restarts | ✅ |
| 🔔 Update Notify | Wrapper- und Baileys-Status im Start- und QR-Flow | ✅ |
| 📱 QR & Pairing | QR-Login, Pairing-Code, Retry-Limits und Callbacks | ✅ |
🆕 Was sich in v1.8.1 geändert hat
- ✅ Neues Session-Lifecycle-Management mit
pauseSession(),stopSession(),resumeSession()unddeleteSession() - ✅ Persistente Session-Registry über
wa_credentials/.neelegirly-session-registry.json - ✅ Neuer Credential-Standard:
${sessionId}_neelegirly - ✅ Alte
_credentials_neelegirly- und_credentials-Ordner werden weiter erkannt und bei Bedarf sauber migriert - ✅
getSessionInfo(),getSessionStatus()undgetAllManagedSessions()für Runtime- und Offline-Status - ✅ Verbesserter Update-Check für
@neelegirly/wa-apiund@neelegirly/baileys - ✅ PM2-freundliches Autostart-Verhalten über
desiredStatestatt blindem Dauer-Reconnect
🚀 Installation
npm
npm install @neelegirly/[email protected] @neelegirly/[email protected] @neelegirly/[email protected] @neelegirly/[email protected] --save-exactyarn
yarn add @neelegirly/[email protected] @neelegirly/[email protected] @neelegirly/[email protected] @neelegirly/[email protected] --exactpnpm
pnpm add @neelegirly/[email protected] @neelegirly/[email protected] @neelegirly/[email protected] @neelegirly/[email protected] --save-exactImport
const waApi = require('@neelegirly/wa-api')import * as waApi from '@neelegirly/wa-api'Der empfohlene Stack für diesen Release ist:
1.8.1 / 2.2.18 / 1.0.28 / 0.1.65.
📖 Quickstart
const waApi = require('@neelegirly/wa-api')
waApi.onConnected((sessionId) => {
console.log(`✅ ${sessionId} ist verbunden`)
})
waApi.onMessageReceived(async (msg) => {
const text = msg.message?.conversation || msg.message?.extendedTextMessage?.text || ''
const jid = msg.key?.remoteJid
if (!jid) return
if (text.toLowerCase() === 'ping') {
await waApi.sendMessage(msg.sessionId, jid, {
text: 'pong 💖 aus dem Neelegirly Glow-up'
})
}
})
async function boot() {
await waApi.checkForUpdates()
await waApi.startSession('main-session', {
printQR: true,
autoStart: true,
retryLimit: 10
})
}
boot().catch(console.error)PM2 / Warm-Restart
async function restoreSessions() {
const restored = await waApi.loadSessionsFromStorage()
console.log('♻️ Wiederhergestellt:', restored)
}
restoreSessions().catch(console.error)loadSessionsFromStorage() startet nur Sessions neu, deren desiredState auf running steht. Pausierte oder gestoppte Sessions bleiben also auch nach einem Neustart absichtlich ruhig. Kleine Sache, große Wirkung.
📲 Session Management
await waApi.startSession('sales', {
printQR: true,
autoStart: true
})
await waApi.startSessionWithPairingCode('support', {
phoneNumber: '491234567890',
autoStart: true
})
await waApi.pauseSession('sales')
await waApi.resumeSession('sales')
await waApi.stopSession('support')
const info = waApi.getSessionInfo('sales')
const status = waApi.getSessionStatus('support')
const managed = waApi.getAllManagedSessions()
console.log(info, status, managed)
await waApi.deleteSession('support')Lifecycle-Status
| Status | Bedeutung |
|--------|-----------|
| new | Session ist bekannt, aber noch nie erfolgreich gestartet worden |
| starting | Start wurde ausgelöst, QR/Initialisierung läuft |
| connecting | Socket verbindet sich oder retryt gerade |
| running | Session ist online |
| paused | Session wurde bewusst pausiert und bleibt aus |
| stopped | Session wurde bewusst gestoppt und bleibt aus |
| deleted | Session und Credentials wurden entfernt |
| error | Session hat einen Fehlerzustand erreicht |
💾 Storage & Credential-Migration
- Credential-Root bleibt
wa_credentials - Neuer Standard-Ordnername:
${sessionId}_neelegirly - Legacy-Ordner
${sessionId}_credentials_neelegirlyund${sessionId}_credentialswerden weiterhin erkannt - Falls nötig, werden Legacy-Ordner automatisch in das neue Schema überführt
- Leere Credential-Ordner werden ignoriert, damit keine Phantom-Sessions entstehen
- Die Session-Registry liegt in
wa_credentials/.neelegirly-session-registry.json
deleteSession() entfernt sowohl neue als auch alte Credential-Ordner. pauseSession() und stopSession() behalten die Credentials dagegen bewusst bei.
🎧 Event Listener
waApi.onQRUpdated(({ sessionId, qr }) => {
console.log('📱 Neuer QR-Code für', sessionId)
console.log(qr)
})
waApi.onPairingCode((sessionId, code) => {
console.log('🔑 Pairing-Code:', sessionId, code)
})
waApi.onConnecting((sessionId) => {
console.log('🟡 Verbinde:', sessionId)
})
waApi.onDisconnected((sessionId) => {
console.log('🔴 Getrennt:', sessionId)
})Verfügbare Listener:
onMessageReceived(listener)onMessageUpdate(listener)onQRUpdated(listener)onConnected(listener)onDisconnected(listener)onConnecting(listener)onPairingCode(listener)
🔔 Update Notify
const snapshot = await waApi.checkForUpdates({ force: true })
console.log(snapshot.waApi)
console.log(snapshot.baileys)
console.log(waApi.getUpdateStatus())checkForUpdates()prüft@neelegirly/wa-apiund@neelegirly/baileys- npm wird bevorzugt, GitHub dient als Fallback
- Das Ergebnis wird gecacht, kann aber mit
{ force: true }neu geladen werden - Der Wrapper setzt automatisch Branding-Kontext für QR- und Statusausgaben im Baileys-Stack
📚 API Overview
| Funktion | Beschreibung |
|----------|--------------|
| checkForUpdates(options?) | Prüft Wrapper- und Baileys-Versionen |
| getUpdateStatus() | Liefert den zuletzt gecachten Update-Snapshot |
| startSession(id, options) | Startet eine Session via QR oder options.method |
| startWhatsapp(id, options) | Veralteter Alias für startSession() |
| startSessionWithPairingCode(id, options) | Startet eine Session direkt per Pairing-Code |
| pauseSession(id) | Pausiert eine Session ohne Credentials zu löschen |
| stopSession(id) | Stoppt eine Session ohne Credentials zu löschen |
| resumeSession(id, options?) | Startet eine pausierte/gestoppte Session erneut |
| deleteSession(id) | Löscht Session, Registry-Eintrag und Credentials |
| getAllSession() | Listet aktuell online laufende Sessions |
| getSession(id) | Liefert den aktiven Socket einer Session |
| getSessionInfo(id) | Liefert detaillierte Session-Metadaten |
| getSessionStatus(id) | Liefert nur den Lifecycle-Status |
| getAllManagedSessions() | Listet alle bekannten Sessions, auch offline |
| loadSessionsFromStorage() | Stellt autostartbare Sessions nach Neustart wieder her |
| sendMessage(sessionId, jid, content, options) | Sendet Nachrichten über eine Session |
Unterstützte Content-Typen
{ text: string }{ image: { url: string }, caption?: string }{ video: { url: string }, caption?: string, gifPlayback?: boolean }{ audio: Stream, mimetype: string, ptt?: boolean }{ document: { url: string, filename?: string }, mimetype: string }{ poll: { name: string, values: string[], selectableCount: number } }{ react: { text: string, key: MessageKey } }{ delete: MessageKey }{ pin: { type: number, time: number, key: MessageKey } }{ contacts: { displayName: string, contacts: Array } }{ location: { degreesLatitude: number, degreesLongitude: number } }{ forward: Message }
⚠️ Wichtige Hinweise
Diese Library ist ausschließlich für
@neelegirly/baileysgedacht.
- ✖️ Kein Spam oder Missbrauch
- ✖️ Keine unerlaubte Überwachung oder Stalkerware
- ✔️ Session-Dateien und
creds.jsonimmer privat halten - ✔️ Für frische Pairing-Boots muss eine
phoneNumbergesetzt sein - ✔️
pauseSession()/stopSession()behalten Credentials,deleteSession()räumt komplett auf
📝 Release Notes 1.8.1
- 💖 Echter Session-Lifecycle statt nur „an oder aus“
- 🧠 Persistente Registry für PM2- und Restart-freundliches Verhalten
- 🗂️ Default-Credential-Suffix auf
_neelegirlykorrigiert - 🔁 Legacy-Credential-Ordner
_credentials_neelegirlyund_credentialsbleiben kompatibel und werden migriert - 🔔 Update-Notify jetzt wrapper- und baileys-aware
- ✨ README auf neuen Runtime-Stand, Storage-Flow und API-Surface gebracht
© 2026 – @neelegirly/wa-api
