# whatsapp-web.js

A WhatsApp API client that connects through the WhatsApp Web browser app

It uses Puppeteer to run a real instance of Whatsapp Web to avoid getting blocked.

NOTE: I can't guarantee you will not be blocked by using this method, although it has worked for me. WhatsApp does not allow bots or unofficial clients on their platform, so this shouldn't be considered totally safe.

## Installation

The module is now available on npm! `npm i whatsapp-web.js`

Please note that Node v8+ is required due to Puppeteer.

## Example usage

    const { Client } = require('whatsapp-web.js');
    const client = new Client();

    client.on('qr', (qr) => {
        // Generate and scan this code with your phone
        console.log('QR RECEIVED', qr);
    });

    client.on('ready', () => {
        console.log('Client is ready!');
    });

    client.on('message', msg => {
        if (msg.body == '!ping') {
            msg.reply('pong');
        }
    });

    client.initialize();

Take a look at example.js for another example with more use cases.

## Supported features

Feature | Status
--- | ---
Send messages | ✅
Receive messages | ✅
Send media (images/audio/documents) | ✅
Send media (video) | ✅ (requires google chrome)
Send stickers | pending
Receive media (images/audio/video/documents) | ✅
Send contact cards | pending
Send location | ✅
Receive location | ✅
Message replies | ✅
Join groups by invite | ✅
Get invite for group | ✅
Modify group info (subject, description) | ✅
Add group participants | ✅
Kick group participants | ✅
Promote/demote group participants | ✅
Mention users | ✅
Get contact info | ✅
Get profile pictures | ✅
Set user status message | ✅

Something missing? Make an issue and let us know!

## Links

- Documentation (preview)
- GitHub

## Contributing

Pull requests are welcome! If you see something you'd like to add, please do. For drastic changes, please open an issue first.

## Base

Base()

## BusinessContact

BusinessContact()
BusinessContact#businessProfile
BusinessContact#getProfilePicUrl()
BusinessContact#id
BusinessContact#isBusiness

BusinessContact#isEnterprise
BusinessContact#isGroup
BusinessContact#isMe
BusinessContact#isMyContact
BusinessContact#isUser

BusinessContact#isWAContact
BusinessContact#name
BusinessContact#number
BusinessContact#pushname
BusinessContact#shortName

## Chat

Chat()
Chat#archive()
Chat#archived
Chat#clearMessages()
Chat#clearState()
Chat#delete()

Chat#fetchMessages(searchOptions)
Chat#id
Chat#isGroup
Chat#isReadOnly
Chat#name
Chat#sendMessage(content, options)

Chat#sendSeen()
Chat#sendStateRecording()
Chat#sendStateTyping()
Chat#timestamp
Chat#unarchive()
Chat#unreadCount

## ChatTypes

ChatTypes.GROUP

ChatTypes.SOLO

ChatTypes.UNKNOWN

## Client

Client()
Client#acceptInvite(inviteCode)
Client#archiveChat()
Client#destroy()
Client#event:auth_failure
Client#event:authenticated
Client#event:change_state
Client#event:disconnected
Client#event:group_join
Client#event:group_leave

Client#event:group_update
Client#event:message
Client#event:message_ack
Client#event:message_create
Client#event:message_revoke_everyone
Client#event:message_revoke_me
Client#event:qr
Client#event:ready
Client#getChatById(chatId)
Client#getChats()

Client#getContactById(contactId)
Client#getContacts()
Client#getState()
Client#initialize()
Client#resetState()
Client#sendMessage(chatId, content, options)
Client#sendSeen(chatId)
Client#setStatus(status)
Client#unarchiveChat()

## ClientInfo

ClientInfo()
ClientInfo#me

ClientInfo#phone
ClientInfo#platform

ClientInfo#pushname

## Contact

Contact()
Contact#getProfilePicUrl()
Contact#id
Contact#isBusiness
Contact#isEnterprise

Contact#isGroup
Contact#isMe
Contact#isMyContact
Contact#isUser
Contact#isWAContact

Contact#name
Contact#number
Contact#pushname
Contact#shortName

## Events

Events.AUTHENTICATED
Events.AUTHENTICATION_FAILURE
Events.DISCONNECTED
Events.GROUP_JOIN
Events.GROUP_LEAVE

Events.GROUP_UPDATE
Events.MESSAGE_ACK
Events.MESSAGE_CREATE
Events.MESSAGE_RECEIVED
Events.MESSAGE_REVOKED_EVERYONE

Events.MESSAGE_REVOKED_ME
Events.QR_RECEIVED
Events.READY
Events.STATE_CHANGED

## GroupChat

GroupChat()
GroupChat.getInviteInfo(inviteCode)
GroupChat.join(inviteCode)
GroupChat#addParticipants(participantIds)
GroupChat#archive()
GroupChat#archived
GroupChat#clearMessages()
GroupChat#clearState()
GroupChat#createdAt
GroupChat#delete()
GroupChat#demoteParticipants(participantIds)

GroupChat#description
GroupChat#fetchMessages(searchOptions)
GroupChat#getInviteCode()
GroupChat#id
GroupChat#isGroup
GroupChat#isReadOnly
GroupChat#leave()
GroupChat#name
GroupChat#owner
GroupChat#participants
GroupChat#promoteParticipants(participantIds)

GroupChat#removeParticipants(participantIds)
GroupChat#revokeInvite()
GroupChat#sendMessage(content, options)
GroupChat#sendSeen()
GroupChat#sendStateRecording()
GroupChat#sendStateTyping()
GroupChat#setDescription(description)
GroupChat#setSubject(subject)
GroupChat#timestamp
GroupChat#unarchive()
GroupChat#unreadCount

## GroupNotification

GroupNotification()
GroupNotification#author
GroupNotification#body
GroupNotification#chatId

GroupNotification#getChat()
GroupNotification#getContact()
GroupNotification#getRecipients()
GroupNotification#id

GroupNotification#recipientIds
GroupNotification#reply(content, options)
GroupNotification#timestamp
GroupNotification#type

## GroupNotificationTypes

GroupNotificationTypes.ADD
GroupNotificationTypes.ANNOUNCE
GroupNotificationTypes.DESCRIPTION

GroupNotificationTypes.INVITE
GroupNotificationTypes.LEAVE
GroupNotificationTypes.PICTURE

GroupNotificationTypes.REMOVE
GroupNotificationTypes.RESTRICT
GroupNotificationTypes.SUBJECT

## Location

Location(latitude, longitude, description)
Location#description

Location#latitude
Location#longitude

## Message

Message()
Message#author
Message#body
Message#broadcast
Message#delete(everyone)
Message#downloadMedia()
Message#from
Message#fromMe

Message#getChat()
Message#getContact()
Message#getMentions()
Message#getQuotedMessage()
Message#hasMedia
Message#hasQuotedMsg
Message#id
Message#isForwarded

Message#location
Message#mentionedIds
Message#reply(content, chatId, options)
Message#timestamp
Message#to
Message#type

## MessageAck

MessageAck.ACK_DEVICE
MessageAck.ACK_ERROR

MessageAck.ACK_PENDING
MessageAck.ACK_PLAYED

MessageAck.ACK_READ
MessageAck.ACK_SERVER

## MessageMedia

MessageMedia(mimetype, data, filename)
MessageMedia#data

MessageMedia#filename
MessageMedia#mimetype

## MessageTypes

MessageTypes.AUDIO
MessageTypes.CONTACT_CARD
MessageTypes.CONTACT_CARD_MULTI
MessageTypes.DOCUMENT

MessageTypes.IMAGE
MessageTypes.LOCATION
MessageTypes.REVOKED
MessageTypes.STICKER

MessageTypes.TEXT
MessageTypes.UNKNOWN
MessageTypes.VIDEO
MessageTypes.VOICE

## PrivateChat

PrivateChat()
PrivateChat#archive()
PrivateChat#archived
PrivateChat#clearMessages()
PrivateChat#clearState()
PrivateChat#delete()

PrivateChat#fetchMessages(searchOptions)
PrivateChat#id
PrivateChat#isGroup
PrivateChat#isReadOnly
PrivateChat#name
PrivateChat#sendMessage(content, options)

PrivateChat#sendSeen()
PrivateChat#sendStateRecording()
PrivateChat#sendStateTyping()
PrivateChat#timestamp
PrivateChat#unarchive()
PrivateChat#unreadCount

## PrivateContact

PrivateContact()
PrivateContact#getProfilePicUrl()
PrivateContact#id
PrivateContact#isBusiness
PrivateContact#isEnterprise

PrivateContact#isGroup
PrivateContact#isMe
PrivateContact#isMyContact
PrivateContact#isUser
PrivateContact#isWAContact

PrivateContact#name
PrivateContact#number
PrivateContact#pushname
PrivateContact#shortName

## Status

Status.AUTHENTICATING

Status.INITIALIZING

Status.READY

## Util

Util()

## WAState

WAState.CONFLICT
WAState.CONNECTED
WAState.DEPRECATED_VERSION
WAState.OPENING

WAState.PAIRING
WAState.PROXYBLOCK
WAState.SMB_TOS_BLOCK
WAState.TIMEOUT

WAState.TOS_BLOCK
WAState.UNLAUNCHED
WAState.UNPAIRED
WAState.UNPAIRED_IDLE