Mattermost Peer-to-Peer Forum

Getting posts for a channel on a specific date


Can anyone point me to the best way to get posts that happened on a particular date using the API? I can see that in the documentation for “Get posts for a channel” that you can’t use since, before or after together. Some help would be greatly appreciated, thank you.

Shouldn't I use `since` parameter for recursive fetch?

The API looks pretty clear to me, perhaps if you post your code and show us where you’re stuck at, we might be able to better assist you.

But the basic would be to call a GET request on /channels/{channel_id}/posts?since=unixtimestamp_of_the_date_you_want (of course don’t forget to replace the channel id and time with the ones u want) other parameters are not required at this point. then you would navigate using page until the end moment you want.

You will get back a json with the order and the posts, a post entry will look something like:


    "id": "string",
    "create_at": 0,
    "update_at": 0,
    "delete_at": 0,
    "user_id": "string",
    "channel_id": "string",
    "root_id": "string",
    "parent_id": "string",
    "original_id": "string",
    "message": "string",
    "type": "string",
    "props": { },
    "hashtag": "string",




    "pending_post_id": "string"


And from there you can check the create_at to see how far u need to go I guess?

If you know the start and end posts ID you could avoid the since and just use the ids directly and then again, use the page to navigate.


Cool, guess there’s no way to avoid iterating through the response. Thanks
for your time


well if you know how many results you’re expecting then you could set the per_page to that value and it would come all in 1 go, alternatively u could just try to set one big value, but that would not be accurate if u don’t know how many posts you’re expecting…