Skip to content

Example HTTP API Messages

Mike Angstadt edited this page Aug 3, 2017 · 14 revisions

Get latest messages

Method: POST

URI: /chats/ROOM_ID/events

Parameters:

Name Value
mode Always set to "messages" (without quotes)
msgCount The number of messages to retrieve.
fkey The fkey

Response example

{
  "events" : [
    {
      "event_type" : 1,
      "time_stamp" : 1501615302,
      "content" : "<b>hello</b> world",
      "user_id" : 1064310,
      "user_name" : "Tristan Wiley",
      "room_id" : 1,
      "message_id" : 38442657,
      "message_stars" : 1
    },
    {
      "event_type" : 1,
      "time_stamp" : 1501636568,
      "content" : "two",
      "user_id" : 13379,
      "user_name" : "Michael",
      "room_id" : 1,
      "message_id" : 38446507,
      "message_edits" : 1
    },  
    {
      "event_type" : 1,
      "time_stamp" : 1501636756,
      "content" : "three",
      "user_id" : 13379,
      "user_name" : "Michael",
      "room_id" : 1,
      "message_id" : 38446514
    }
  ],
  "time" : 77918739,
  "sync" : 1501636602,
  "ms" : 0
}

Notes

  • Events are sorted by timestamp.
  • The "message_edits" field is only present if the message has been edited.
  • The "message_stars" field is only present if the message has been starred.

Post message

Method: POST

URI: /chats/ROOM_ID/messages/new

Parameters:

Name Value
text The message to post
fkey The fkey

Response example

{
  "id" : 38469011,
  "time" : 1501724999
}

Notes

  • Chat messages are formatted in Markdown.
  • Stack Overflow Chat will only recognize the Markdown formatting on messages that are not fixed-width and that do not exceed a single line of text (fixed-width messages are formatted in a monospace font; each line in a fixed-width message begins with four spaces)
  • Single-lined messages cannot be longer than 500 characters.
Clone this wiki locally