GET
/
chat
/
Message.json
curl -X GET \
-H "QB-Token: d23b555a6f9b6db4e3ebfd5e02a8e238e5012bba" \
https://api.quickblox.com/chat/Message.json?chat_dialog_id=5d75393ba28f9a17e1cb0f9e
{
  "skip": 0,
  "limit": 100,
  "items": [
    {
      "_id": "5d755856a0eb47411e0b72a9",
      "attachments": [],
      "chat_dialog_id": "5d75393ba28f9a17e1cb0f9e",
      "created_at": "2019-09-08T19:36:54Z",
      "date_sent": 1567971414,
      "delivered_ids": [
        96753878
      ],
      "message": "Hi guys",
      "read_ids": [
        96753878
      ],
      "recipient_id": 0,
      "sender_id": 96753878,
      "updated_at": "2019-09-08T19:36:54Z",
      "read": 0
    },
    {
      "_id": "5d76a618a28f9a1edfcb0f9b",
      "age": "25",
      "attachments": [
        {
          "type": "image",
          "id": "47863"
        },
        {
          "type": "image",
          "id": "47863"
        }
      ],
      "chat_dialog_id": "5d75393ba28f9a17e1cb0f9e",
      "created_at": "2019-09-09T19:20:56Z",
      "date_sent": 1568056856,
      "delivered_ids": [
        96753878
      ],
      "message": "Hi guys!",
      "read_ids": [
        96753878
      ],
      "recipient_id": 343,
      "sender_id": 96753878,
      "updated_at": "2019-09-09T19:20:56Z",
      "read": 0
    }
  ]
}

Recipes

All retrieved chat messages will be marked as read after request.
Messages will be marked in 2 cases:

  • if the current user ID is in occupants_ids field for type=2 (GROUP) dialog;
  • if dialog’s type=1 (PUBLIC) dialog.

Search operators

The request can contain all, some or none of the next search operators:

OperatorDescription
ltLess Than operator

Types: number, string, date

Applicable to fields: date_sent, sender_id, recipient_id, updated_at

Example:

date_sent[lt]=1556829805

Description:

Will return messages with date_sent less than 1556829805.
lteLess Than or Equal to operator

Types: number, string, date

Applicable to fields: date_sent, sender_id, recipient_id, updated_at

Example: updated_at[lte]=1556829805

Will return messages with updated_at less than or equal 1556829805.
gtGreater Than operator

Types: number, string, date

Applicable to fields: date_sent, sender_id, recipient_id, updated_at

Example:
date_sent[gt]=1556829805

Will return messages with date_sent greater than 1556829805.
gteGreater Than or Equal to operator

Types: number, string, date

Applicable to fields: date_sent, sender_id, recipient_id, updated_at

Example:
date_sent[gte]=1556829805

Will return messages with date_sent greater than or equal 1556829805.
neNot Equal to operator

Types: number, string, date

Applicable to fields: _id, message, date_sent, sender_id, recipient_id

Example:
recipient_id[ne]=9988237

Will return messages with recipient_id not equal to 9988237.
inContained IN array operator

Types: number, string, date

Applicable to fields: date_sent, sender_id, recipient_id

Example:
sender_id[in]=91419276,91419395

Will return messages with sender_id equal to 91419276 and equal to 91419395.
ninNot contained IN array

Types: number, string, date

Applicable to fields: date_sent, sender_id, recipient_id

Example:
recipient_id[nin]=91419276,91419395

Will return messages with recipient_id not equal to 91419276 and 91419395.
orOR operator

Types: number, string, date

Applicable to fields: date_sent, sender_id, recipient_id

Example:
sender_id[or]=91419390,96753878

Will return messages with sender_id equal to 91419390 or 96753878.
ctnContains substring operator

Types: string

Applicable to fields: message

Example: message[ctn]=party

Returns messages which text contains the word “party”.

Sort operators

Next sorting operators are allowed:

OperatorDescription
sort_ascTypes: all types

Example:
sort_asc=field_name

Search results will be sorted by the specified field in ascending order.
sort_descTypes: all types

Example:
sort_desc=field_name

Search results will be sorted by the specified field in descending order.

Query Parameters

chat_dialog_id
string
required
ID of the dialog.
{message_field_N}
string
Search records with the field that contains the specified value. Can be many 1..N.
{message_field_N}[{search_operator}]
string
Filters records with field which contains value according to specified value and operator. Can be many 1..N.
mark_as_read
integer
Mark the requested message(s) as read. Set mark_as_read=1 to perform. As a result, when the message(s) is retreived by the opponent, the opponent ID is added to the array of read_ids field. Works only if the message had the unread status previously, not backwards. You can update message status using the Update Message request.
limit
string
default:"100"
Limit search results to N records. Useful for pagination.
skip
string
default:"0"
Skip N records in search results. Useful for pagination.
count
string
Count search results. Response will contain only a count of found records.
sort_desc
string
Search results will be sorted by a specified field in descending order.
sort_asc
string
Search results will be sorted by a specified field in ascending order.

Headers

QB-Token
string
required
A user or application session token. See our Authentication page to learn more about session tokens. Must be used either QB-Token or Authorization.
Authorization
string
default:"ApiKey {your_api_key}"
API key from Dashboard. Expected format: ApiKey {your_api_key}. Must be used either QB-Token or Authorization.
On-Behalf-Of
string
User ID. The user ID of the user on whose behalf the request is being made.

Responses

curl -X GET \
-H "QB-Token: d23b555a6f9b6db4e3ebfd5e02a8e238e5012bba" \
https://api.quickblox.com/chat/Message.json?chat_dialog_id=5d75393ba28f9a17e1cb0f9e
{
  "skip": 0,
  "limit": 100,
  "items": [
    {
      "_id": "5d755856a0eb47411e0b72a9",
      "attachments": [],
      "chat_dialog_id": "5d75393ba28f9a17e1cb0f9e",
      "created_at": "2019-09-08T19:36:54Z",
      "date_sent": 1567971414,
      "delivered_ids": [
        96753878
      ],
      "message": "Hi guys",
      "read_ids": [
        96753878
      ],
      "recipient_id": 0,
      "sender_id": 96753878,
      "updated_at": "2019-09-08T19:36:54Z",
      "read": 0
    },
    {
      "_id": "5d76a618a28f9a1edfcb0f9b",
      "age": "25",
      "attachments": [
        {
          "type": "image",
          "id": "47863"
        },
        {
          "type": "image",
          "id": "47863"
        }
      ],
      "chat_dialog_id": "5d75393ba28f9a17e1cb0f9e",
      "created_at": "2019-09-09T19:20:56Z",
      "date_sent": 1568056856,
      "delivered_ids": [
        96753878
      ],
      "message": "Hi guys!",
      "read_ids": [
        96753878
      ],
      "recipient_id": 343,
      "sender_id": 96753878,
      "updated_at": "2019-09-09T19:20:56Z",
      "read": 0
    }
  ]
}