curl -X GET \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
https://api.quickblox.com/chat/Dialog.json?limit=2
{
"total_entries": 6,
"skip": 0,
"limit": 2,
"items": [
{
"_id": "5d75393ba28f9a17e1cb0f9e",
"created_at": "2019-09-08T17:24:11Z",
"last_message": "sure, I can wait",
"last_message_date_sent": 1567971414,
"last_message_id": "5d755856a0eb47411e0b72a9",
"last_message_user_id": 96753878,
"name": "New Year party",
"occupants_ids": [
96753878,
96754523,
96830631,
96831328,
96831397
],
"admin_ids": [],
"photo": "68123",
"type": 2,
"updated_at": "2019-09-08T19:36:54Z",
"user_id": 96753878,
"xmpp_room_jid": "76730_5d75393ba28f9a17e1cb0f9e@muc.chat.quickblox.com",
"unread_messages_count": 0,
"is_join_required": 1
},
{
"_id": "5d753421a28f9a2596cb0f98",
"created_at": "2019-09-08T17:02:26Z",
"last_message": "let's do it at 7pm",
"last_message_date_sent": 1567971391,
"last_message_id": "5d75583fa0eb473c350b72ab",
"last_message_user_id": 96753878,
"name": "Daniel's birthday",
"occupants_ids": [
96753878,
96754523,
96830631,
96831328,
96831397
],
"admin_ids": [],
"photo": "68123",
"type": 2,
"updated_at": "2019-09-08T19:36:31Z",
"user_id": 96753878,
"xmpp_room_jid": "76730_5d753421a28f9a2596cb0f98@muc.chat.quickblox.com",
"unread_messages_count": 0,
"is_join_required": 1
}
]
}
List Dialogs
Retrieve a list of chat dialogs. You can list dialogs using specific search criteria.
curl -X GET \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
https://api.quickblox.com/chat/Dialog.json?limit=2
{
"total_entries": 6,
"skip": 0,
"limit": 2,
"items": [
{
"_id": "5d75393ba28f9a17e1cb0f9e",
"created_at": "2019-09-08T17:24:11Z",
"last_message": "sure, I can wait",
"last_message_date_sent": 1567971414,
"last_message_id": "5d755856a0eb47411e0b72a9",
"last_message_user_id": 96753878,
"name": "New Year party",
"occupants_ids": [
96753878,
96754523,
96830631,
96831328,
96831397
],
"admin_ids": [],
"photo": "68123",
"type": 2,
"updated_at": "2019-09-08T19:36:54Z",
"user_id": 96753878,
"xmpp_room_jid": "76730_5d75393ba28f9a17e1cb0f9e@muc.chat.quickblox.com",
"unread_messages_count": 0,
"is_join_required": 1
},
{
"_id": "5d753421a28f9a2596cb0f98",
"created_at": "2019-09-08T17:02:26Z",
"last_message": "let's do it at 7pm",
"last_message_date_sent": 1567971391,
"last_message_id": "5d75583fa0eb473c350b72ab",
"last_message_user_id": 96753878,
"name": "Daniel's birthday",
"occupants_ids": [
96753878,
96754523,
96830631,
96831328,
96831397
],
"admin_ids": [],
"photo": "68123",
"type": 2,
"updated_at": "2019-09-08T19:36:31Z",
"user_id": 96753878,
"xmpp_room_jid": "76730_5d753421a28f9a2596cb0f98@muc.chat.quickblox.com",
"unread_messages_count": 0,
"is_join_required": 1
}
]
}
Recipes
Filter dialogs by custom field
Filter dialogs by custom field
1. Set a custom object class
CoolDialog custom object class.See this section to learn how to create a custom object class.curl -X GET \
-H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
https://api.quickblox.com/chat/Dialog.json?data[class_name]=CoolDialog&data[category]=friends
2. Set a custom object field
friends field of the CoolDialog custom object class.curl -X GET \
-H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
https://api.quickblox.com/chat/Dialog.json?data[class_name]=CoolDialog&data[category]=friends
3. As a result, the API returns all dialogs by the specified custom object field.
curl -X GET \
-H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
https://api.quickblox.com/chat/Dialog.json?data[class_name]=CoolDialog&data[category]=friends
Display total number of all dialogs
Display total number of all dialogs
1. Specify if you want to count dialogs
count to 1.curl -X GET\
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
https://api.quickblox.com/chat/Dialog.json?count=1
2. As a result, the API returns a total number of all dialogs that exist in the system.
curl -X GET\
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
https://api.quickblox.com/chat/Dialog.json?count=1
Get dialog by dialog ID
Get dialog by dialog ID
1. Set the dialog ID
curl -X GET \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d "_id=5d75393ba28f9a17e1cb0f9e" \
https://api.quickblox.com/chat/Dialog.json
2. As a result, the specified dialog is returned
curl -X GET \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d "_id=5d75393ba28f9a17e1cb0f9e" \
https://api.quickblox.com/chat/Dialog.json
Filter dialogs by type
Filter dialogs by type
1. Set a search operator for a field
in operator is applied to a type field.curl -X GET \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d "type[in]=1,2&sort_desc=last_message_date_sent&limit=3" \
https://api.quickblox.com/chat/Dialog.json
2. Set a sort operator for a field
sort_desc operator is applied to the last_message_date_sent field.curl -X GET \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d "type[in]=1,2&sort_desc=last_message_date_sent&limit=3" \
https://api.quickblox.com/chat/Dialog.json
3. Set a limit for a number of dialogs on the page
limit parameter.Here, the number of dialogs on the page is limited to 3.curl -X GET \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d "type[in]=1,2&sort_desc=last_message_date_sent&limit=3" \
https://api.quickblox.com/chat/Dialog.json
4. As a result, the API returns all public and group dialogs.
curl -X GET \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
-d "type[in]=1,2&sort_desc=last_message_date_sent&limit=3" \
https://api.quickblox.com/chat/Dialog.json
Get dialogs with API key
Get dialogs with API key
1. Use 'Authorization' header to pass API key
curl -X GET \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
https://api.quickblox.com/chat/Dialog.json
2. Use 'On-Behalf-Of' header to pass user_id
curl -X GET \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
https://api.quickblox.com/chat/Dialog.json
3. As a result, the API returns all public and group dialogs.
curl -X GET \
-H "Authorization: ApiKey 28irlNAGasWDSupO9Vw0BBMZfuHrAUYKpmroS9yBORI" \
-H "On-Behalf-Of: 123" \
https://api.quickblox.com/chat/Dialog.json
| Operator | Description |
|---|---|
| lt | Less Than operator Types: number, string, date Applicable to fields: last_message_date_sent, created_at, updated_at Example: ?updated_at[lt]=1556829805 Will return dialogs with updated_at less than 1556829805. |
| lte | Less Than or Equal to operator Types: number, string, date Applicable to fields: last_message_date_sent, created_at, updated_at Example: ?last_message_date_sent[lte]=1556735709 Will return dialogs with last_message_date_sent less than or equal 1556735709. |
| gt | Greater Than operator Types: number, string, date Applicable to fields: last_message_date_sent, created_at, updated_at Example: ?last_message_date_sent[gt]=1556735709 Will return dialogs with last_message_date_sent greater than 1556735709. |
| gte | Greater Than or Equal to operator Types: number, string, date Applicable to fields: last_message_date_sent, created_at, updated_at Example: ?last_message_date_sent[gt]=1556735709 Will return dialogs with last_message_date_sent greater than 1556735709. |
| ne | Not Equal to operator Types: number, string, date Applicable to fields: _id, name, last_message_date_sent Example: ?_id[ne]=5cc9bb58a28f9a406659d777 Will return dialogs with _id not equal to 5cc9bb58a28f9a406659d777. |
| in | Contained IN array operator Types: number, string, date Applicable to fields: type, last_message_date_sent, name Example: ?type[in]=1,2 Will return dialogs with type equal to 1 and equal to 2. |
| nin | Not contained IN array operator Types: number, string, date Applicable to fields: last_message_date_sent Example: ?last_message_date_sent[nin]=1556739654, 1556739987 Will return dialogs with last_message_date_sent not equal to 1556739654 and 1556739987. |
| all | ALL contained IN array Types: number Applicable to fields: occupants_ids, admin_ids Example: ?occupants_ids[all]=91103344,91142495 Will return dialogs with occupants_ids equal to 91103344 and 91142495 (both). |
| ctn | Contains substring operator Types: string Applicable to field: name Example: ?name[ctn]=party Returns dialogs whose name contains the word “party”. |
| Operator | Description |
|---|---|
| sort_asc | Types: all types Example: sort_asc=field_name Search results will be sorted by the specified field in ascending order. |
| sort_desc | Types: all types Example: sort_desc=field_name Search results will be sorted by the specified field in descending order. |
Query Parameters
Added in v2.4.5.
Headers
ApiKey {your_api_key}. Must be used either QB-Token or Authorization.Responses
curl -X GET \
-H "QB-Token: 1319b4991186601ccf4df2d0fa89565f68012bba" \
https://api.quickblox.com/chat/Dialog.json?limit=2
{
"total_entries": 6,
"skip": 0,
"limit": 2,
"items": [
{
"_id": "5d75393ba28f9a17e1cb0f9e",
"created_at": "2019-09-08T17:24:11Z",
"last_message": "sure, I can wait",
"last_message_date_sent": 1567971414,
"last_message_id": "5d755856a0eb47411e0b72a9",
"last_message_user_id": 96753878,
"name": "New Year party",
"occupants_ids": [
96753878,
96754523,
96830631,
96831328,
96831397
],
"admin_ids": [],
"photo": "68123",
"type": 2,
"updated_at": "2019-09-08T19:36:54Z",
"user_id": 96753878,
"xmpp_room_jid": "76730_5d75393ba28f9a17e1cb0f9e@muc.chat.quickblox.com",
"unread_messages_count": 0,
"is_join_required": 1
},
{
"_id": "5d753421a28f9a2596cb0f98",
"created_at": "2019-09-08T17:02:26Z",
"last_message": "let's do it at 7pm",
"last_message_date_sent": 1567971391,
"last_message_id": "5d75583fa0eb473c350b72ab",
"last_message_user_id": 96753878,
"name": "Daniel's birthday",
"occupants_ids": [
96753878,
96754523,
96830631,
96831328,
96831397
],
"admin_ids": [],
"photo": "68123",
"type": 2,
"updated_at": "2019-09-08T19:36:31Z",
"user_id": 96753878,
"xmpp_room_jid": "76730_5d753421a28f9a2596cb0f98@muc.chat.quickblox.com",
"unread_messages_count": 0,
"is_join_required": 1
}
]
}
Was this page helpful?