@mataram/wa
v0.11.0
Published
A WebSockets library for interacting with WhatsApp Web
Maintainers
Readme
@mataram/wa
TypeScript library for the WhatsApp Web API. Direct WebSocket connection — no browser, no Selenium.
npm install @mataram/waCara Termudah — create-mataram-bot
Bikin project bot langsung jadi dengan satu perintah:
npx create-mataram-bot my-bot 6281234567890
cd my-bot
npm install
npm startBot langsung bisa pairing code + auto-reconnect + 8 perintah interaktif.
Quick Start
import makeWASocket, { useMultiFileAuthState, DisconnectReason, Browsers } from '@mataram/wa'
const { state, saveCreds } = await useMultiFileAuthState('auth_info')
const sock = makeWASocket({
auth: state,
browser: Browsers.macOS('Chrome'),
})
sock.ev.on('creds.update', saveCreds)
sock.ev.on('connection.update', ({ connection, lastDisconnect }) => {
if (connection === 'open') console.log('Connected:', sock.user?.id)
if (connection === 'close') {
const code = lastDisconnect?.error?.output?.statusCode
if (code !== DisconnectReason.loggedOut) {
setTimeout(() => process.exit(), 3000)
}
}
})
if (!state.creds.registered) {
const code = await sock.requestPairingCode('6281234567890')
console.log('Pairing code:', code)
}Documentation
Full interactive documentation is available in docs/index.html — bilingual (🇮🇩 Indonesia + 🇬🇧 English), mobile-first, with code examples for every feature.
Features
| Category | Methods |
|---|---|
| Connection | makeWASocket, requestPairingCode, logout, end, waitForConnectionUpdate |
| Send Messages | sendMessage — text, image, video, audio, document, sticker, poll, event, album, location, contacts, reactions, edit, delete, pin, forward, view once, disappearing |
| Interactive | Quick reply buttons, template buttons (URL/call), list menus, native flow, rich text |
| Groups | groupCreate, groupMetadata, groupParticipantsUpdate, groupUpdateSubject, groupUpdateDescription, groupSettingUpdate, groupToggleEphemeral, groupInviteCode, groupRevokeInvite, groupAcceptInvite, groupGetInviteInfo, groupLeave, groupJoinApprovalMode, groupMemberAddMode, groupFetchAllParticipating, groupRequestParticipantsList, groupRequestParticipantsUpdate |
| Communities | communityCreate, communityCreateGroup, communityLinkGroup, communityUnlinkGroup, communityFetchLinkedGroups, communityMetadata, communityParticipantsUpdate, communityUpdateSubject, communityUpdateDescription, communityInviteCode, communityAcceptInvite, communitySettingUpdate, communityToggleEphemeral, communityLeave |
| Newsletter | newsletterCreate, newsletterFollow, newsletterUnfollow, newsletterMetadata, newsletterUpdateName, newsletterUpdateDescription, newsletterUpdatePicture, newsletterRemovePicture, newsletterReactMessage, newsletterMute, newsletterUnmute, newsletterSubscribers, newsletterFetchMessages, subscribeNewsletterUpdates, newsletterAdminCount, newsletterChangeOwner, newsletterDemote, newsletterDelete |
| Events | messages.upsert, messages.update, messages.delete, messages.reaction, messages.media-update, message-receipt.update, connection.update, creds.update, chats.upsert, chats.update, chats.delete, contacts.upsert, contacts.update, groups.upsert, groups.update, group-participants.update, presence.update, call, blocklist.update, blocklist.set, messaging-history.set, messaging-history.status, newsletter.reaction, newsletter.view, newsletter-settings.update, newsletter-participants.update, labels.edit, labels.association, settings.update, lid-mapping.update, message-capping.update |
| Chat | readMessages, sendReceipt, chatModify (archive, mute, pin, delete, clear, markRead), star, sendPresenceUpdate, presenceSubscribe, fetchStatus, fetchDisappearingDuration, addOrEditContact, removeContact |
| Profile | updateProfileName, updateProfileStatus, updateProfilePicture, removeProfilePicture, profilePictureUrl, fetchBlocklist, updateBlockStatus |
| Privacy | updateLastSeenPrivacy, updateOnlinePrivacy, updateProfilePicturePrivacy, updateStatusPrivacy, updateReadReceiptsPrivacy, updateMessagesPrivacy, updateCallPrivacy, updateGroupsAddPrivacy, updateDefaultDisappearingMode, updateDisableLinkPreviewsPrivacy |
| Business | getBusinessProfile, updateBussinesProfile, updateCoverPhoto, removeCoverPhoto, getCatalog, getCollections, productCreate, productUpdate, productDelete, getOrderDetails |
| Labels | addLabel, addChatLabel, removeChatLabel, addMessageLabel, removeMessageLabel, addOrEditQuickReply, removeQuickReply, updateMemberLabel |
| Calls | createCallLink (audio/video), rejectCall |
| Media | downloadContentFromMessage, downloadMediaMessage, updateMediaMessage, waUploadToServer |
| Signal | assertSessions, uploadPreKeys, rotateSignedPreKey, digestKeyBundle, sendPeerDataOperationMessage |
| USync | onWhatsApp, executeUSyncQuery |
| Account | fetchAccountReachoutTimelock, fetchNewChatMessageCap, fetchPrivacySettings |
| Utilities | fetchLatestVersion, getContentType, getDevice, BufferJSON, makeCacheableSignalKeyStore, jidDecode, jidNormalizedUser, areJidsSameUser |
Config
const sock = makeWASocket({
auth, // Required
browser: Browsers.macOS('Chrome'), // Browser identity
version: [2, 3000, 1035194821], // WA Web version
connectTimeoutMs: 20000, // Connection timeout
keepAliveIntervalMs: 30000, // Ping interval
markOnlineOnConnect: true, // Show online
syncFullHistory: true, // Sync history
fireInitQueries: true, // Auto-init queries
emitOwnEvents: true, // Own action events
logger: pino({ level: 'silent' }), // Logger
agent: socksProxyAgent, // WS proxy
fetchAgent: socksAgent, // HTTP proxy
getMessage: async (key) => store.get(key),
cachedGroupMetadata: async (jid) => cache.get(jid),
})Error Codes
| Code | Constant | Meaning |
|---|---|---|
| 401 | DisconnectReason.loggedOut | Session expired — re-auth required |
| 403 | DisconnectReason.forbidden | Account restricted |
| 408 | DisconnectReason.timedOut | Request timed out |
| 428 | DisconnectReason.connectionClosed | Connection closed |
| 440 | DisconnectReason.connectionReplaced | Logged in elsewhere |
| 500 | DisconnectReason.badSession | Corrupted session |
| 515 | DisconnectReason.restartRequired | Normal restart after pairing |
| 411 | DisconnectReason.multideviceMismatch | Multi-device beta not joined |
License
MIT © 2025 Ibra Decode
Not affiliated with WhatsApp or Meta.
