Documentation Index
Fetch the complete documentation index at: https://zapo.to/llms.txt
Use this file to discover all available pages before exploring further.
A JID (Jabber ID) is how WhatsApp addresses every entity. zapo exports a set of helpers to build and classify them, all from the package root:
import { parsePhoneJid, isGroupJid, splitJid } from 'zapo-js'
JID shapes
| Entity | Example |
|---|
| User (phone) | 5511999999999@s.whatsapp.net |
| Group | 123456789-987654@g.us |
| Newsletter / channel | 120363000000000000@newsletter |
| Status broadcast | status@broadcast |
| LID (privacy id) | 123456789@lid |
Building JIDs
// Phone number → user JID
parsePhoneJid('5511999999999') // '5511999999999@s.whatsapp.net'
// Normalize anything into a recipient JID (accepts a number or string)
normalizeRecipientJid('5511999999999')
// Strip a device suffix down to the base user JID
toUserJid('5511999999999:12@s.whatsapp.net') // '5511999999999@s.whatsapp.net'
// Build a device-scoped JID
buildDeviceJid('5511999999999@s.whatsapp.net', 12)
Parsing & splitting
splitJid('5511999999999@s.whatsapp.net') // { user, server }
parseJidFull(jid) // ParsedJid with full breakdown
parseSignalAddressFromJid(jid) // { user, device }
Classifying JIDs
Boolean predicates for routing logic:
| Helper | True for |
|---|
isGroupJid(jid) | Group (@g.us) |
isGroupOrBroadcastJid(jid) | Group or broadcast |
isBroadcastJid(jid) | Broadcast list |
isStatusBroadcastJid(jid) | status@broadcast |
isNewsletterJid(jid) | Newsletter (@newsletter) |
isLidJid(jid) | LID (@lid) |
isBotJid(jid) | A bot (@bot) |
isHostedDeviceJid(jid) | Hosted device |
client.on('message', (event) => {
if (isGroupJid(event.chatJid!)) {
console.log('a group message')
}
})
Constants
The full set of protocol constants is exported as frozen WA_* objects (the library uses these instead of TypeScript enums). The most commonly used:
| Constant | Contains |
|---|
WA_DEFAULTS | Default timeouts, the status-broadcast JID, the default device browser, … |
WA_BROWSERS | Browser identifiers for the device fingerprint. |
WA_PRIVACY_CATEGORIES / WA_PRIVACY_VALUES | Privacy setting names and allowed values. |
WA_DISCONNECT_REASONS / WA_LOGOUT_REASONS | Reason strings on connection events. |
WA_MESSAGE_TYPES / WA_MESSAGE_TAGS | Message classification. |
WA_NODE_TAGS / WA_XMLNS | Protocol node tags and XML namespaces. |
WA_APP_STATE_COLLECTIONS | App-state collection names. |
import { WA_DEFAULTS, WA_LOGOUT_REASONS } from 'zapo-js'
await client.logout(WA_LOGOUT_REASONS.USER_INITIATED)
Associated string-literal types are also exported for annotation: WaPrivacyCategory, WaPrivacySettingName, WaPrivacyValue, WaDisconnectReason, WaLogoutReason, WaConnectionCode, WaStreamErrorCode, WaFailureReasonCode, and ParsedJid.
Other utilities
| Export | Purpose |
|---|
proto | The full protobuf namespace — build raw Proto.IMessage payloads. |
delay(ms) | Promise-based sleep. |
parseUsyncResultEnvelope | Parse a USync IQ result envelope. |