waha icon indicating copy to clipboard operation
waha copied to clipboard

[Feature Request] Support limit/pagination/offset on /messages endpoint

Open HuangDaHui opened this issue 1 year ago • 3 comments

Hi,I am using the plus version. As a developer, I think this interface needs to add an offset parameter, so that the query speed will be much faster, because I often need to compare chat records to detect whether there are miss webhooks. It would be even better if it could be filtered based on TimeSpan. I look forward to your improvement.

HuangDaHui avatar Jul 19 '24 06:07 HuangDaHui

And I found that the WEBJS version cannot obtain the document media URL through this interface

HuangDaHui avatar Jul 19 '24 07:07 HuangDaHui

downloadMedia=true { "id": "[email protected]_3EB01366AE65565E416039", "timestamp": 1721288456, "from": "[email protected]", "fromMe": true, "to": "[email protected]", "body": "funding%e6%9c%aa%e5%88%9b%e5%bb%ba.xls", "hasMedia": false, "ack": 3, "ackName": "READ", "vCards": [], "_data": { "id": { "fromMe": true, "remote": "[email protected]", "id": "3EB01366AE65565E416039", "_serialized": "[email protected]_3EB01366AE65565E416039" }, "viewed": false, "body": "", "type": "document", "t": 1721288456, "notifyName": "", "from": { "server": "c.us", "user": "8615018078614", "_serialized": "[email protected]" }, "to": { "server": "c.us", "user": "8618138420573", "_serialized": "[email protected]" }, "ack": 3, "invis": false, "star": false, "kicNotified": false, "caption": "funding%e6%9c%aa%e5%88%9b%e5%bb%ba.xls", "deprecatedMms3Url": "https://mmg.whatsapp.net/v/t62.7119-24/21478540_889421156558106_5735655572489448540_n.enc?ccb=11-4&oh=01_Q5AaIBM2_1gCyGxoNTM8eFeYrQ-2SNbw0SJ8xwO33b1sou6T&oe=66C039FE&_nc_sid=5e03e0&mms3=true", "directPath": "/v/t62.7119-24/21478540_889421156558106_5735655572489448540_n.enc?ccb=11-4&oh=01_Q5AaIBM2_1gCyGxoNTM8eFeYrQ-2SNbw0SJ8xwO33b1sou6T&oe=66C039FE&_nc_sid=5e03e0", "mimetype": "application/vnd.ms-excel", "filehash": "3opQNR6iWVazAlmMxfrdIFKIVKLN55GEb8E5jXU/TrI=", "encFilehash": "N7qhAjE/FaXvP1C64RRjgREkTQV8SjbcsU1iydfMV7Y=", "size": 20480, "filename": "funding%e6%9c%aa%e5%88%9b%e5%bb%ba.xls", "mediaKey": "cfk1NNCR9bNCDm6f4/EG5q1Nwtcl78Sofw2UbTtrAP0=", "mediaKeyTimestamp": 1721288453, "pageCount": 0, "isFromTemplate": false, "pollInvalidated": false, "isSentCagPollCreation": false, "latestEditMsgKey": null, "latestEditSenderTimestampMs": null, "mentionedJidList": [], "groupMentions": [], "isEventCanceled": false, "eventInvalidated": false, "isVcardOverMmsDocument": false, "isCaptionByUser": false, "isForwarded": false, "labels": [], "hasReaction": false, "productHeaderImageRejected": false, "lastPlaybackProgress": 0, "isDynamicReplyButtonsMsg": false, "isCarouselCard": false, "parentMsgId": null, "isMdHistoryMsg": false, "stickerSentTs": 0, "isAvatar": false, "lastUpdateFromServerTs": 0, "invokedBotWid": null, "botTargetSenderJid": null, "bizBotType": null, "botResponseTargetId": null, "botPluginType": null, "botPluginReferenceIndex": null, "botPluginSearchProvider": null, "botPluginSearchUrl": null, "botPluginSearchQuery": null, "botPluginMaybeParent": false, "botReelPluginThumbnailCdnUrl": null, "botMsgBodyType": null, "reportingTokenInfo": null, "requiresDirectConnection": false, "bizContentPlaceholderType": null, "hostedBizEncStateMismatch": false, "senderOrRecipientAccountTypeHosted": false, "placeholderCreatedWhenAccountIsHosted": false, "links": [] } }

HuangDaHui avatar Jul 19 '24 07:07 HuangDaHui

And I found that the WEBJS version cannot obtain the document media URL through this interface

When you request it - could you check the docker logs? And may be enable "debug" for the session to see more logs about what is happneing? Just tested it with 2024.7.6, worked with images and xlsx file with no issue :thinking:

Ideally in a new issue, if you can :pray:

patron:PRO

devlikepro avatar Jul 22 '24 14:07 devlikepro

Added in 2024.10.9

https://waha.devlike.pro/docs/how-to/chats/#get-messages


GET /api/{session}/chats/{chatId}/messages?limit=10

Available parameters:

  • downloadMedia=true - download media files (images, files) or not
  • [email protected] - chatId, phone number
    • chatId=all - get messages from all chats (works on NOWEBengine only)
  • limit=100 - limit the number of chats to return
  • offset=0 - skip the number of chats from the start
  • filter.timestamp.lte=1727745026 - filter messages by timestamp less than or equal to 1727745026
  • filter.timestamp.gte=1727745026 - filter messages by timestamp greater than or equal to 1727745026
  • filter.fromMe=false - filter messages from me (by default shows all messages)

Get 10 messages from 1727745026 timestamp, not from me

GET /api/{session}/chats/{chatId}/messages?limit=10&filter.timestamp.gte=1727745026&filter.fromMe=false

👉 If you have more messages - you can set offset flag (increase it always for limit amount, even if you get less messages)

GET /api/{session}/chats/{chatId}/messages?limit=10&offset=10&filter.timestamp.gte=1727745026&filter.fromMe=false

patron:PRO

devlikepro avatar Oct 27 '24 08:10 devlikepro