List Friends
curl --request GET \
--url https://{appId}.api-{region}.cometchat.io/v3/users/{uid}/friends \
--header 'apikey: <api-key>'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/users/{uid}/friends"
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/users/{uid}/friends', 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}/friends",
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/users/{uid}/friends"
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/users/{uid}/friends")
.header("apikey", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/users/{uid}/friends")
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": [
{
"uid": "cometchat-uid-6",
"name": "Barry Allen",
"link": "https://cometchat.com",
"avatar": "https://assets.cometchat.io/sampleapp/v2/groups/cometchat-guid-1.webp",
"metadata": {
"email": "user@email.com",
"contactNumber": "0123456789"
},
"status": "offline",
"role": "manager",
"createdAt": 1638354015,
"updatedAt": 1638354799,
"conversationId": "cometchat-uid-4_user_cometchat-uid-6"
},
{
"uid": "cometchat-uid-2",
"name": "George Alan",
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp",
"status": "offline",
"role": "default",
"createdAt": 1629869270,
"updatedAt": 1630308676,
"conversationId": "cometchat-uid-2_user_cometchat-uid-4"
},
{
"uid": "cometchat-uid-3",
"name": "George Alan",
"link": "https://data-us.cometchat.io/assets",
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp",
"metadata": {
"contactNumber": "0123456789"
},
"status": "offline",
"role": "default",
"blockedByMe": true,
"blockedByMeAt": 1638346853,
"blockedAt": 1638346853,
"createdAt": 1629869270,
"updatedAt": 1638351060,
"conversationId": "cometchat-uid-3_user_cometchat-uid-4"
}
],
"meta": {
"pagination": {
"total": 0,
"count": 5,
"per_page": 100,
"current_page": 1,
"total_pages": 1
},
"cursor": {
"updatedAt": 1638354799,
"affix": "prepend"
}
}
}Friends
List Friends
The API allows to fetch friends for a given UID.
GET
/
users
/
{uid}
/
friends
List Friends
curl --request GET \
--url https://{appId}.api-{region}.cometchat.io/v3/users/{uid}/friends \
--header 'apikey: <api-key>'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/users/{uid}/friends"
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/users/{uid}/friends', 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}/friends",
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/users/{uid}/friends"
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/users/{uid}/friends")
.header("apikey", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/users/{uid}/friends")
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": [
{
"uid": "cometchat-uid-6",
"name": "Barry Allen",
"link": "https://cometchat.com",
"avatar": "https://assets.cometchat.io/sampleapp/v2/groups/cometchat-guid-1.webp",
"metadata": {
"email": "user@email.com",
"contactNumber": "0123456789"
},
"status": "offline",
"role": "manager",
"createdAt": 1638354015,
"updatedAt": 1638354799,
"conversationId": "cometchat-uid-4_user_cometchat-uid-6"
},
{
"uid": "cometchat-uid-2",
"name": "George Alan",
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp",
"status": "offline",
"role": "default",
"createdAt": 1629869270,
"updatedAt": 1630308676,
"conversationId": "cometchat-uid-2_user_cometchat-uid-4"
},
{
"uid": "cometchat-uid-3",
"name": "George Alan",
"link": "https://data-us.cometchat.io/assets",
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp",
"metadata": {
"contactNumber": "0123456789"
},
"status": "offline",
"role": "default",
"blockedByMe": true,
"blockedByMeAt": 1638346853,
"blockedAt": 1638346853,
"createdAt": 1629869270,
"updatedAt": 1638351060,
"conversationId": "cometchat-uid-3_user_cometchat-uid-4"
}
],
"meta": {
"pagination": {
"total": 0,
"count": 5,
"per_page": 100,
"current_page": 1,
"total_pages": 1
},
"cursor": {
"updatedAt": 1638354799,
"affix": "prepend"
}
}
}For the complete error reference, see Error Guide.
Authorizations
API Key with fullAccess scope(i.e. Rest API Key from the Dashboard).
Path Parameters
An UID of a user.
Query Parameters
Searches for given keyword in friends list (either UID or name).
Number of friends to be fetched in a request. The default value is 100 and the maximum value is 1000.
Page Number.
Was this page helpful?
⌘I