Skip to main content

Check if ID exists on WhatsApp

Verify whether a phone number is registered on WhatsApp.
const [result] = await sock.onWhatsApp(jid)
if (result.exists) console.log(`${jid} exists on WhatsApp, as jid: ${result.jid}`)
phoneNumber
string
required
One or more phone numbers to check (with country code)
Returns an array of objects with jid and exists properties for each phone number checked.

Fetch user status

Retrieve the status message of a user.
const status = await sock.fetchStatus(jid)
console.log('status: ' + status)
jids
string
required
One or more JIDs to fetch status for

Fetch profile picture URL

Get the profile picture URL for a user or group.
// for low res picture
const ppUrl = await sock.profilePictureUrl(jid)
console.log(ppUrl)

// for high res picture
const ppUrl = await sock.profilePictureUrl(jid, 'image')
jid
string
required
The JID of the user or group
type
'preview' | 'image'
default:"'preview'"
Resolution type:
  • preview - Low resolution thumbnail
  • image - High resolution image
timeoutMs
number
Optional timeout in milliseconds for the request

Fetch business profile

Retrieve business profile information such as description or category.
const profile = await sock.getBusinessProfile(jid)
console.log('business description: ' + profile.description + ', category: ' + profile.category)
jid
string
required
The JID of the business account
This method only works for business accounts. Regular user accounts will not return profile information.

Query chat history

Fetch historical messages from a chat or group.
const msg = await getOldestMessageInChat(jid) // implement this on your end
await sock.fetchMessageHistory(
    50, // quantity (max: 50 per query)
    msg.key,
    msg.messageTimestamp
)
count
number
required
Number of messages to fetch (maximum 50 per query)
oldestMsgKey
WAMessageKey
required
The message key of the oldest message you have in the chat
oldestMsgTimestamp
number | Long
required
The timestamp of the oldest message
Messages will be received in the messaging.history-set event. You need to have the oldest message in the chat to use this method.

Build docs developers (and LLMs) love