waha icon indicating copy to clipboard operation
waha copied to clipboard

[Feature Request] Support limit/pagination on /chats and /contacts endpoints

Open tristan-thar opened this issue 1 year ago • 2 comments

Is your feature request related to a problem? Please describe. Some of our accounts have thousands of active chats and contacts. Currently we're using WebJS, however the whole container crashes when we try to query the /chats and /contacts endpoints.

Describe the solution you'd like

The ability to either set a limit (maybe v1? of this?) in the query to these endpoints would be a good starting point, however in the future I'd love to see a pagination of some sorts.

As far as I can see WhatsApp Web uses some sort of "infinite load" pagination.

Additionally, maybe a search would be good too for both chats and contacts in case we are looking for one where we don't know the ID.

Describe alternatives you've considered

The alternative would be to not use these endpoints if your WhatsApp account have more chats/contacts then the system can handle.

Additional context We're running Whapi Plus on a 64GB Ram, 8 CPU machine, and the current ram utlization is arount 20 GB, while the CPU is around 15%, so well below the limits of the VPS.

Thank you!

patron:ADVANCED

tristan-thar avatar Jun 13 '24 17:06 tristan-thar

Related to

  • https://github.com/devlikeapro/waha/issues/331
  • https://github.com/devlikeapro/waha/issues/278

patron:PRO

devlikepro avatar Jun 14 '24 07:06 devlikepro

Added limit and offset parameters to GET /api/{session}/chats endpoint.

  • Read more about Get all chats
  • Build: 2024.6.4
  • Engine: WEBJS
  • Engine: NOWEB

Get all chats

Get all chats

GET /api/{session}/chats
  • limit - limit the number of chats to return
  • offset - skip the number of chats from the start

If you see timeout or the request takes too long - consider using limit parameter to get chats in smaller chunks

GET /api/{session}/chats?limit=100&offset=0

patron:PRO

devlikepro avatar Jun 17 '24 03:06 devlikepro

Added in 2024.10.9

  • https://waha.devlike.pro/docs/how-to/chats/#pagination
  • https://waha.devlike.pro/docs/how-to/contacts/#pagination

Pagination

If you see timeout or the request takes too long - consider using limit parameter to get contacts in smaller chunks

GET /api/{session}/contacts/all?limit=100&offset=0&sortBy=id&sortOrder=asc
  • limit=100 - limit the number of chats to return
  • offset=0 - skip the number of chats from the start
  • sortBy={field} - sort by field
    • sortBy=id - sort by contact id
    • sortBy=name - sort by contact name
  • sortOrder=desc|asc - sort order
    • desc - descending order (A-Z)
    • asc - ascending order (Z-A)

patron:PRO

devlikepro avatar Oct 27 '24 08:10 devlikepro