Get User Conversation
curl --request GET \
--url https://{appId}.api-{region}.cometchat.io/v3/users/{uid}/conversation \
--header 'apikey: <api-key>' \
--header 'onBehalfOf: <onbehalfof>'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/users/{uid}/conversation"
headers = {
"onBehalfOf": "<onbehalfof>",
"apikey": "<api-key>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {onBehalfOf: '<onbehalfof>', apikey: '<api-key>'}};
fetch('https://{appId}.api-{region}.cometchat.io/v3/users/{uid}/conversation', 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/users/{uid}/conversation",
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>",
"onBehalfOf: <onbehalfof>"
],
]);
$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/users/{uid}/conversation"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("onBehalfOf", "<onbehalfof>")
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/users/{uid}/conversation")
.header("onBehalfOf", "<onbehalfof>")
.header("apikey", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/users/{uid}/conversation")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["onBehalfOf"] = '<onbehalfof>'
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": "cometchat-uid-4",
"receiverType": "group",
"receiver": "project-group",
"category": "action",
"type": "groupMember",
"data": {
"action": "unbanned",
"entities": {
"by": {
"entity": {
"uid": "cometchat-uid-4",
"name": "Susan Marie",
"role": "default",
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-4.webp",
"status": "offline",
"createdAt": 1629869270
},
"entityType": "user"
},
"on": {
"entity": {
"uid": "cometchat-uid-3",
"link": "https://www.cometchat.com",
"name": "Nancy Grace",
"role": "default",
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp",
"status": "offline",
"createdAt": 1629869270,
"updatedAt": 1629964825,
"conversationId": "cometchat-uid-3_user_cometchat-uid-4"
},
"entityType": "user"
},
"for": {
"entity": {
"guid": "project-group",
"icon": "https://assets.cometchat.io/sampleapp/v2/groups/cometchat-guid-1.webp",
"name": "Project Group1",
"type": "private",
"owner": "cometchat-uid-4",
"createdAt": 1630071341,
"updatedAt": 1630305525,
"updatedBy": "cometchat-uid-4",
"description": "project related discussions between members",
"membersCount": 4,
"conversationId": "group_project-group"
},
"entityType": "group"
}
}
},
"sentAt": 1630305562,
"updatedAt": 1630305562
},
"conversationWith": {
"guid": "project-group",
"name": "Project Group1",
"description": "project related discussions between members",
"icon": "https://assets.cometchat.io/sampleapp/v2/groups/cometchat-guid-1.webp",
"type": "private",
"scope": "participant",
"membersCount": 4,
"joinedAt": 1630071782,
"conversationId": "group_project-group",
"hasJoined": true,
"createdAt": 1630071341,
"owner": "cometchat-uid-4",
"updatedAt": 1630308875,
"updatedBy": "cometchat-uid-4"
}
}
]
}Conversations
Get User Conversation
Fetch and filter conversation data by user to check unread counts, participants, and message history in one request.
GET
/
users
/
{uid}
/
conversation
Get User Conversation
curl --request GET \
--url https://{appId}.api-{region}.cometchat.io/v3/users/{uid}/conversation \
--header 'apikey: <api-key>' \
--header 'onBehalfOf: <onbehalfof>'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/users/{uid}/conversation"
headers = {
"onBehalfOf": "<onbehalfof>",
"apikey": "<api-key>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {onBehalfOf: '<onbehalfof>', apikey: '<api-key>'}};
fetch('https://{appId}.api-{region}.cometchat.io/v3/users/{uid}/conversation', 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/users/{uid}/conversation",
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>",
"onBehalfOf: <onbehalfof>"
],
]);
$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/users/{uid}/conversation"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("onBehalfOf", "<onbehalfof>")
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/users/{uid}/conversation")
.header("onBehalfOf", "<onbehalfof>")
.header("apikey", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/users/{uid}/conversation")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["onBehalfOf"] = '<onbehalfof>'
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": "cometchat-uid-4",
"receiverType": "group",
"receiver": "project-group",
"category": "action",
"type": "groupMember",
"data": {
"action": "unbanned",
"entities": {
"by": {
"entity": {
"uid": "cometchat-uid-4",
"name": "Susan Marie",
"role": "default",
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-4.webp",
"status": "offline",
"createdAt": 1629869270
},
"entityType": "user"
},
"on": {
"entity": {
"uid": "cometchat-uid-3",
"link": "https://www.cometchat.com",
"name": "Nancy Grace",
"role": "default",
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp",
"status": "offline",
"createdAt": 1629869270,
"updatedAt": 1629964825,
"conversationId": "cometchat-uid-3_user_cometchat-uid-4"
},
"entityType": "user"
},
"for": {
"entity": {
"guid": "project-group",
"icon": "https://assets.cometchat.io/sampleapp/v2/groups/cometchat-guid-1.webp",
"name": "Project Group1",
"type": "private",
"owner": "cometchat-uid-4",
"createdAt": 1630071341,
"updatedAt": 1630305525,
"updatedBy": "cometchat-uid-4",
"description": "project related discussions between members",
"membersCount": 4,
"conversationId": "group_project-group"
},
"entityType": "group"
}
}
},
"sentAt": 1630305562,
"updatedAt": 1630305562
},
"conversationWith": {
"guid": "project-group",
"name": "Project Group1",
"description": "project related discussions between members",
"icon": "https://assets.cometchat.io/sampleapp/v2/groups/cometchat-guid-1.webp",
"type": "private",
"scope": "participant",
"membersCount": 4,
"joinedAt": 1630071782,
"conversationId": "group_project-group",
"hasJoined": true,
"createdAt": 1630071341,
"owner": "cometchat-uid-4",
"updatedAt": 1630308875,
"updatedBy": "cometchat-uid-4"
}
}
]
}For the complete error reference, see Error Guide.
Authorizations
Was this page helpful?