[Feature Request] Support limit/pagination/offset on /messages endpoint
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.
And I found that the WEBJS version cannot obtain the document media URL through this interface
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": [] } }
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:
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 numberchatId=all- get messages from all chats (works on NOWEBengine only)
limit=100- limit the number of chats to returnoffset=0- skip the number of chats from the startfilter.timestamp.lte=1727745026- filter messages by timestamp less than or equal to1727745026filter.timestamp.gte=1727745026- filter messages by timestamp greater than or equal to1727745026filter.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