# API Get latest messages from a channel

**URL:** <https://forum.mattermost.com/t/api-get-latest-messages-from-a-channel/1169>\
**Category:** Troubleshooting\
**Created:** [March 26, 2016, 7:40pm UTC](https://forum.mattermost.com/t/api-get-latest-messages-from-a-channel/1169 "2016-03-26T19:40:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tht13](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@tht13](https://forum.mattermost.com/u/tht13)\
**Post date:** [March 26, 2016, 7:40pm UTC](https://forum.mattermost.com/t/api-get-latest-messages-from-a-channel/1169/1 "2016-03-26T19:40:30Z")

</div>

What api url can I use to get the most recent messages from a channel? I know I can use a outgoing webhook to get messages as they are sent but I would like to retrieve previous messages like the last 5 sent. Slack has a channel.history api method, however this did not seem to work here.

Documentation of the possible web service api urls would be really helpful. I checked the github logs and there doesn’t seem to have been any progress here for 2 months.

---

<div class="post-metadata">

**Author:** ![limey98](https://avatars.discourse-cdn.com/v4/letter/l/48db29/32.png) [@limey98](https://forum.mattermost.com/u/limey98)\
**Post date:** [March 27, 2016, 9:15am UTC](https://forum.mattermost.com/t/api-get-latest-messages-from-a-channel/1169/2 "2016-03-27T09:15:34Z")

</div>

You have `api/v1/channels/<channel id>/posts/<offset>/<limit>` which will get a set number of posts (specified by `<limit>`) from the channel, offset from the latest by a set number (specified by `<offset>`).  
For example, `api/v1/channel/<channel id>/posts/5/10` would get 10 posts, skipping over the latest 5.

There is also `api/v1/channels/<channel id>/posts/<UNIX timestamp>` that will get all posts created or modified since the date specified.

If you want live updates, its better to set up a WebSocket connection. Then you will get near-instant notifications of new and edited posts, among other things. Let me know if that’s what you want and I can give a quick rundown of it.

---

<div class="post-metadata">

**Author:** ![harish](https://avatars.discourse-cdn.com/v4/letter/h/47e85d/32.png) [@harish](https://forum.mattermost.com/u/harish)\
**Post date:** [January 24, 2017, 1:28pm UTC](https://forum.mattermost.com/t/api-get-latest-messages-from-a-channel/1169/3 "2017-01-24T13:28:58Z")

</div>

how to get channel\_id?
