@wppconnect/wa-js - v4.1.0
    Preparing search index...

    Function queryUsernameExists

    • Check if a WhatsApp username (@username) exists

      Some accounts protect their username with a PIN. When the account has PIN protection enabled, this function returns { keyRequired: true } instead of contact info. Pass the numeric PIN as key to unlock the result.

      Parameters

      • username: string
      • Optionalkey: string

      Returns Promise<QueryUsernameExistsResult | QueryUsernameExistsKeyRequired | null>

      // Basic lookup
      const result = await WPP.contact.queryUsernameExists('someusername');
      if (result && 'keyRequired' in result) {
      // Username is PIN-protected — prompt the user for the PIN
      } else if (result) {
      console.log(result.wid); // The contact's WID
      }

      // With PIN
      const result = await WPP.contact.queryUsernameExists('someusername', '1234');