List conversations
curl --request GET \
--url https://{appid}.api-{region}.cometchat.io/v3/conversations \
--header 'apikey: <api-key>'import requests
url = "https://{appid}.api-{region}.cometchat.io/v3/conversations"
headers = {"apikey": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {apikey: '<api-key>'}};
fetch('https://{appid}.api-{region}.cometchat.io/v3/conversations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{appid}.api-{region}.cometchat.io/v3/conversations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"apikey: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{appid}.api-{region}.cometchat.io/v3/conversations"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("apikey", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://{appid}.api-{region}.cometchat.io/v3/conversations")
.header("apikey", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appid}.api-{region}.cometchat.io/v3/conversations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["apikey"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"data": [
{
"conversationId": "group_project-group",
"conversationType": "group",
"unreadMessageCount": "0",
"createdAt": 1630071782,
"updatedAt": 1630481413,
"lastMessage": {
"id": "50",
"conversationId": "group_project-group",
"sender": "superhero4",
"receiverType": "group",
"receiver": "project-group",
"category": "action",
"type": "groupMember",
"data": {
"action": "unbanned",
"entities": {
"by": {
"entity": {
"uid": "superhero4",
"name": "Wolverine",
"role": "default",
"avatar": "https://data-us.cometchat.io/assets/images/avatars/wolverine.png",
"status": "offline",
"createdAt": 1629869270
},
"entityType": "user"
},
"on": {
"entity": {
"uid": "superhero3",
"link": "https://data-us.cometchat.io/assets",
"name": "Captain America",
"role": "default",
"avatar": "https://data-us.cometchat.io/assets/images/avatars/captainamerica.png",
"status": "offline",
"createdAt": 1629869270,
"updatedAt": 1629964825,
"conversationId": "superhero3_user_superhero4"
},
"entityType": "user"
},
"for": {
"entity": {
"guid": "project-group",
"icon": "http://placehold.it/120x120&text=image1",
"name": "Project Group1",
"type": "private",
"owner": "superhero4",
"createdAt": 1630071341,
"updatedAt": 1630305525,
"updatedBy": "superhero4",
"description": "project related discussions between members",
"membersCount": 4,
"conversationId": "group_project-group"
},
"entityType": "group"
}
}
},
"sentAt": 1630305562,
"updatedAt": 1630305562,
"receipts": {
"data": [
[]
]
}
},
"conversationWith": {
"guid": "project-group",
"name": "Project Group1",
"description": "project related discussions between members",
"icon": "http://placehold.it/120x120&text=image1",
"type": "private",
"scope": "participant",
"membersCount": 4,
"joinedAt": 1630071782,
"conversationId": "group_project-group",
"hasJoined": true,
"createdAt": 1630071341,
"owner": "superhero4",
"updatedAt": 1630308875,
"updatedBy": "superhero4"
}
}
],
"meta": {
"pagination": {
"total": 1,
"count": 1,
"per_page": 100,
"current_page": 1,
"total_pages": 1
}
}
}Conversations
List conversations
Fetching all the conversations
GET
/
conversations
List conversations
curl --request GET \
--url https://{appid}.api-{region}.cometchat.io/v3/conversations \
--header 'apikey: <api-key>'import requests
url = "https://{appid}.api-{region}.cometchat.io/v3/conversations"
headers = {"apikey": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {apikey: '<api-key>'}};
fetch('https://{appid}.api-{region}.cometchat.io/v3/conversations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{appid}.api-{region}.cometchat.io/v3/conversations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"apikey: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{appid}.api-{region}.cometchat.io/v3/conversations"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("apikey", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://{appid}.api-{region}.cometchat.io/v3/conversations")
.header("apikey", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appid}.api-{region}.cometchat.io/v3/conversations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["apikey"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"data": [
{
"conversationId": "group_project-group",
"conversationType": "group",
"unreadMessageCount": "0",
"createdAt": 1630071782,
"updatedAt": 1630481413,
"lastMessage": {
"id": "50",
"conversationId": "group_project-group",
"sender": "superhero4",
"receiverType": "group",
"receiver": "project-group",
"category": "action",
"type": "groupMember",
"data": {
"action": "unbanned",
"entities": {
"by": {
"entity": {
"uid": "superhero4",
"name": "Wolverine",
"role": "default",
"avatar": "https://data-us.cometchat.io/assets/images/avatars/wolverine.png",
"status": "offline",
"createdAt": 1629869270
},
"entityType": "user"
},
"on": {
"entity": {
"uid": "superhero3",
"link": "https://data-us.cometchat.io/assets",
"name": "Captain America",
"role": "default",
"avatar": "https://data-us.cometchat.io/assets/images/avatars/captainamerica.png",
"status": "offline",
"createdAt": 1629869270,
"updatedAt": 1629964825,
"conversationId": "superhero3_user_superhero4"
},
"entityType": "user"
},
"for": {
"entity": {
"guid": "project-group",
"icon": "http://placehold.it/120x120&text=image1",
"name": "Project Group1",
"type": "private",
"owner": "superhero4",
"createdAt": 1630071341,
"updatedAt": 1630305525,
"updatedBy": "superhero4",
"description": "project related discussions between members",
"membersCount": 4,
"conversationId": "group_project-group"
},
"entityType": "group"
}
}
},
"sentAt": 1630305562,
"updatedAt": 1630305562,
"receipts": {
"data": [
[]
]
}
},
"conversationWith": {
"guid": "project-group",
"name": "Project Group1",
"description": "project related discussions between members",
"icon": "http://placehold.it/120x120&text=image1",
"type": "private",
"scope": "participant",
"membersCount": 4,
"joinedAt": 1630071782,
"conversationId": "group_project-group",
"hasJoined": true,
"createdAt": 1630071341,
"owner": "superhero4",
"updatedAt": 1630308875,
"updatedBy": "superhero4"
}
}
],
"meta": {
"pagination": {
"total": 1,
"count": 1,
"per_page": 100,
"current_page": 1,
"total_pages": 1
}
}
}Authorizations
Headers
UID of the user on whose behalf the action is performed.
If onBehalfOf header is not passed,then list Conversations API will be ordered based on uid, updatedAt and then conversationWith
If onBehalfOf header is passed, then list Conversations API will be ordered based on updatedAt and then conversationWith.