Skip to content

API: Messages

Simon Bartlett edited this page Feb 5, 2015 · 2 revisions

Table of Contents

GET /messages

Retrieves a list of messages.

For consistent paging, you should consider setting reverse sorting to 'false'.

Query Parameters
Param Example Default Description
room 54b33a8f79deea2116f15c1c Filter rooms by Room ID
since_id 54b343437f5681b404fe74a1 Returns results with an ID greater than (more recent than) the specified ID.
from 2015-02-02T01:43:19Z Returns results with a posted date greater than (more recent than) the specified date.
to 2016-02-02T01:43:19Z Returns results with a posted date less than or equal to the specified date.
skip 100 0 Specifies the number of messages to skip
take 100 500 Specifies the number of messages to return (Max: 5000)
reverse false true Reverses order of messages
expand owner,room Include detailed information for owner or room
Example 1
GET /messages
[
  {
    "id": "54b343437f5681b404fe74a1",
    "room": "54b33a8f79deea2116f15c1c",
    "owner": "54b33a7a79deea2116f15c1b",
    "text": "Life finds a way",
    "posted": "2015-01-12T03:45:07.265Z"
  },
  ...
]
Example 2
GET /messages?expand=owner,room
[
  {
    "id": "54b343437f5681b404fe74a1",
    "room": {
      "id": "54b33a8f79deea2116f15c1c",
      "name": "The Control room"
    },
    "owner": {
      "id": "54b33a7a79deea2116f15c1b",
      "username": "ray",
      "displayName": "Ray Arnold",
      "avatar": "a74b7ad4ae60e8189e06b572e78366de"
    },
    "text": "Hold on to your butts.",
    "posted": "2015-01-12T03:45:07.265Z"
  },
  ...
]

POST /messages

Creates a message.

Body Parameters
Property Description
room Room ID
text Message text
Example
POST /messages

{
  "text":"It's a unix system! I know this!",
  "room":"54d039092fbe9a8104ad9390"
}
201 Created

{
  "id": "54d044fc2fbe9a8104ad9391",
  "room": "54d039092fbe9a8104ad9390",
  "owner": "54c55225bbdccfca06cdd490",
  "text": "It's a unix system! I know this!",
  "posted": "2015-02-03T03:48:12.600Z"
}

GET /rooms/:room/messages

An alias for GET /messages, that overrides the room query parameter using the room path parameter.

Path Parameters
Parameter Description
room Room ID or slug

POST /rooms/:room/messages

An alias for POST /messages, that overrides the room query parameter using the room path parameter.

Path Parameters
Parameter Description
room Room ID or slug