pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
14.62k stars 3.48k forks source link

getChats() only returning 500 chats #2414

Closed Yusufkulcu closed 7 months ago

Yusufkulcu commented 11 months ago

Is there an existing issue for this?

Describe the bug

I have a whatsapp account with 500+ chats. getChats function returns only 500 chats but I need more

Expected behavior

getChats function lists over 500 chats

Steps to Reproduce the Bug or Issue

synchronous

Relevant Code

const qrcode = require('qrcode-terminal');

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

client.on('qr', qr => { qrcode.generate(qr, {small: true}); });

client.on('ready', () => { console.log('Client is ready!'); const chats = await client.getChats(); console.log(chats.length); // even if you have more than 500 chats, 500 will be printed });

client.initialize();

Browser Type

Chromium

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

whatsapp-web.js : 23 Os : macos Phone : ios

Additional context

No response

Jhongt796 commented 10 months ago

It is a limit of WhatsApp Web, since when you log in it does not load more than 500 chats

I recently tried to read data from a WhatsApp that contained more than 3,000 chats, what I can tell you after several tests is the following:

1) The limit is related to WhatsApp Web, not this library. 2) After I can visually (There is no event to read this) make sure the "Syncing" bar fills to 100% and reload the program, I was able to raise that limit from 500 to 800 (Increases slightly if you continually reboot) 3) Little by little, the more you leave WhatsApp web on with this library and interact in the chats, the contacts added with their name will load and in turn load more chats

After all that, by using it for a while (In my case I restarted it every day at 2AM) after a few days (approximately 4 days) I managed to have more than 2000 chats loaded.