Getting the Messages

Get Messages

GET https://{{tekos_homeserver}}/_matrix/client/r0/rooms/{roomId}/messages

Path Parameters

NameTypeDescription

roomId

string

The room to send the event to.

tekos_homeserver

string

Your home server address, the default one is m.tekos.co, but we suggest to use env.get('BASE_URL') this variable should contain address to your home server stored on our S3 server.

Query Parameters

NameTypeDescription

filter

string

A JSON RoomEventFilter to filter returned events with.

limit

integer

The maximum number of events to return. Default 10.

dir

string

The direction to return events from. One of: ["b","f"]

to

string

The token to stop returning events at. This token can be obtained from a prev_batch token returned for each room by the sync endpoint, or from a start or end token returned by a previous request to this endpoint.

from

string

The token to start returning events from. This token can be obtained from a prev_batch token returned for each room by the sync API, or from a start or end token returned by a previous request to this endpoint

access_token

string

Access Token of the user or bot that will send a message.

{
  "start": "t47429-4392820_219380_26003_2265",
  "end": "t47409-4357353_219380_26003_2265",
  "chunk": [
    {
      "content": {
        "body": "This is an example text message",
        "msgtype": "m.text",
        "format": "org.matrix.custom.html",
        "formatted_body": "<b>This is an example text message</b>"
      },
      "type": "m.room.message",
      "event_id": "$143273582443PhrSn:example.org",
      "room_id": "!636q39766251:example.com",
      "sender": "@example:example.org",
      "origin_server_ts": 1432735824653,
      "unsigned": {
        "age": 1234
      }
    },
    {
      "content": {
        "name": "The room name"
      },
      "type": "m.room.name",
      "event_id": "$143273582443PhrSn:example.org",
      "room_id": "!636q39766251:example.com",
      "sender": "@example:example.org",
      "origin_server_ts": 1432735824653,
      "unsigned": {
        "age": 1234
      },
      "state_key": ""
    },
    {
      "content": {
        "body": "Gangnam Style",
        "url": "mxc://example.org/a526eYUSFFxlgbQYZmo442",
        "info": {
          "thumbnail_url": "mxc://example.org/FHyPlCeYUSFFxlgbQYZmoEoe",
          "thumbnail_info": {
            "mimetype": "image/jpeg",
            "size": 46144,
            "w": 300,
            "h": 300
          },
          "w": 480,
          "h": 320,
          "duration": 2140786,
          "size": 1563685,
          "mimetype": "video/mp4"
        },
        "msgtype": "m.video"
      },
      "type": "m.room.message",
      "event_id": "$143273582443PhrSn:example.org",
      "room_id": "!636q39766251:example.com",
      "sender": "@example:example.org",
      "origin_server_ts": 1432735824653,
      "unsigned": {
        "age": 1234
      }
    }
  ]
}

Response format:

Parameter

Type

Description

start

string

The token the pagination starts from. If dir=b this will be the token supplied in from.

end

string

The token the pagination ends at. If dir=b this token should be used again to request even earlier events.

chunk

[RoomEvent]

A list of room events. The order depends on the dir parameter. For dir=b events will be in reverse-chronological order, for dir=f in chronological order, so that events start at the from point.

state

[RoomStateEvent]

A list of state events relevant to showing the chunk. For example, if lazy_load_members is enabled in the filter then this may contain the membership events for the senders of events in the chunk.

Unless include_redundant_members is true, the server may remove membership events which would have already been sent to the client in prior calls to this endpoint, assuming the membership of those members has not changed.

RoomEvent

Parameter

Type

Description

content

object

Required. The fields in this object will vary depending on the type of event. When interacting with the REST API, this is the HTTP body.

type

string

Required. The type of event. This SHOULD be namespaced similar to Java package naming conventions e.g. 'com.example.subdomain.event.type'

event_id

string

Required. The globally unique event identifier.

sender

string

Required. Contains the fully-qualified ID of the user who sent this event.

origin_server_ts

integer

Required. Timestamp in milliseconds on originating homeserver when this event was sent.

unsigned

UnsignedData

Contains optional extra information about the event.

room_id

string

Required. The ID of the room associated with this event. Will not be present on events that arrive through /sync, despite being required everywhere else.

RoomStateEvent

Parameter

Type

Description

content

object

Required. The fields in this object will vary depending on the type of event. When interacting with the REST API, this is the HTTP body.

type

string

Required. The type of event. This SHOULD be namespaced similar to Java package naming conventions e.g. 'com.example.subdomain.event.type'

event_id

string

Required. The globally unique event identifier.

sender

string

Required. Contains the fully-qualified ID of the user who sent this event.

origin_server_ts

integer

Required. Timestamp in milliseconds on originating homeserver when this event was sent.

unsigned

UnsignedData

Contains optional extra information about the event.

room_id

string

Required. The ID of the room associated with this event. Will not be present on events that arrive through /sync, despite being required everywhere else.

prev_content

EventContent

Optional. The previous content for this event. If there is no previous content, this key will be missing.

state_key

string

Required. A unique key which defines the overwriting semantics for this piece of room state. This value is often a zero-length string. The presence of this key makes this event a State Event. State keys starting with an @ are reserved for referencing user IDs, such as room members. With the exception of a few events, state events set with a given user's ID as the state key MUST only be set by that user.

UnsignedData

Parameter

Type

Description

age

integer

The time in milliseconds that has elapsed since the event was sent. This field is generated by the local homeserver, and may be incorrect if the local time on at least one of the two servers is out of sync, which can cause the age to either be negative or greater than it actually is.

redacted_because

Event

Optional. The event that redacted this event, if any.

transaction_id

string

The client-supplied transaction ID, if the client being given the event is the same one which sent it.

Example request:

GET /_matrix/client/r0/rooms/%21636q39766251%3Aexample.com/messages?from=s345_678_333&dir=b&limit=3&filter=%7B%22contains_url%22%3Atrue%7D HTTP/1.1

Last updated