Crm · Social posts
Get social media statistics
Returns the social media publications of a period and of the period of the same length right before it: how many deliveries were published, their views, their engagement (likes, comments and shares) and the engagement rate of the publications with views, attributed to the day they were published. Also returns the publications per month and platform, the views and engagement per month, every channel with its publications, views, followers and whether the platform provides statistics for it, and the five publications with the most views. With an account ID, the figures only cover that channel and the daily figures of the channel are returned as well; the channel list always covers every channel. Figures exist only for publications and days the statistics were fetched for
Permissions
Send an API key of the organization in the path, using the X-API-Key header.
Permission checks in detail
Required permissions
social.read
Request
Path parameters
-
organizationIdidrequired
Query parameters
-
fromDatestringrequired -
toDatestringrequired -
accountIdidrequirednullable
curl --fail-with-body --silent --show-error --max-time 30 --globoff \
--request GET 'https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/crm/communication/socialPosts/statistics' \
--header 'X-API-Key: YOUR_API_KEY'const response = await fetch("https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/crm/communication/socialPosts/statistics", {
method: "GET",
headers: {
"X-API-Key": "YOUR_API_KEY"
},
redirect: 'error',
signal: AbortSignal.timeout(30_000),
});
if (!response.ok) throw new Error(`campai HTTP ${response.status}`);
const text = await response.text();
const result = text ? JSON.parse(text) : null;
console.log(JSON.stringify(result, null, 2));<?php
$context = stream_context_create(['http' => [
'method' => 'GET',
'header' => [
'X-API-Key: YOUR_API_KEY',
],
'timeout' => 30,
'follow_location' => 0,
'ignore_errors' => true,
]]);
$text = @file_get_contents('https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/crm/communication/socialPosts/statistics', false, $context);
preg_match('/^HTTP\/\S+ (\d{3})/', $http_response_header[0] ?? '', $match);
$status = (int) ($match[1] ?? 0);
if ($text === false || $status < 200 || $status >= 300) {
throw new RuntimeException("campai HTTP $status (0 means no response)");
}
$result = $text === '' ? null : json_decode($text, true, 512, JSON_THROW_ON_ERROR);
echo json_encode($result, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR), PHP_EOL;
Response
200 Successful response
Content-Type: application/json
-
summaryobject11 properties
-
publishedintegerat least 0
-
previousPublishedintegerat least 0
-
viewsintegerat least 0
-
previousViewsintegerat least 0
-
likesintegerat least 0
-
commentsintegerat least 0
-
sharesintegerat least 0
-
engagementintegerat least 0
-
previousEngagementintegerat least 0
-
engagementRatenumbernullableat least 0
-
previousEngagementRatenumbernullableat least 0
-
-
monthsobject[]4 properties
-
datestring -
publishedobject[]2 properties
-
platformstringfacebooklinkedintiktokinstagrampinterestyoutubeblueskythreadswordpressgoogleMyBusiness -
countintegerat least 0
-
-
viewsintegerat least 0
-
engagementintegerat least 0
-
-
channelsobject[]11 properties
-
_idid -
namestring -
providerstring13 values
facebooklinkedinlinkedinPagetiktoktiktokBusinessinstagraminstagramStandalonepinterestyoutubeblueskythreadswordpressgoogleMyBusiness -
platformstringfacebooklinkedintiktokinstagrampinterestyoutubeblueskythreadswordpressgoogleMyBusiness -
statusstringconnecteddisconnectedreconnectRequired -
statisticsStatusstringpendingavailablemissingPermissionunsupported -
publishedintegerat least 0
-
viewsintegernullableat least 0
-
engagementintegernullableat least 0
-
followersintegernullableat least 0
-
followersGainedintegernullableat least 0
-
-
topPostsobject[]10 properties
-
postIdid -
accountIdid -
accountNamestring -
providerstring13 values
facebooklinkedinlinkedinPagetiktoktiktokBusinessinstagraminstagramStandalonepinterestyoutubeblueskythreadswordpressgoogleMyBusiness -
platformstringfacebooklinkedintiktokinstagrampinterestyoutubeblueskythreadswordpressgoogleMyBusiness -
textstring -
urlstringnullable -
publishedAtstring · date-time -
viewsintegernullableat least 0
-
engagementintegerat least 0
-
-
daysobject[]nullable12 properties
-
followersintegernullableat least 0
-
followersGainedintegernullableat least 0
-
followersLostintegernullableat least 0
-
viewsintegernullableat least 0
-
reachintegernullableat least 0
-
engagementsintegernullableat least 0
-
clicksintegernullableat least 0
-
watchMinutesintegernullableat least 0
-
websiteClicksintegernullableat least 0
-
callsintegernullableat least 0
-
directionRequestsintegernullableat least 0
-
datestring
-
{
"summary": {
"published": 0,
"previousPublished": 0,
"views": 0,
"previousViews": 0,
"likes": 0,
"comments": 0,
"shares": 0,
"engagement": 0,
"previousEngagement": 0,
"engagementRate": 0,
"previousEngagementRate": 0
},
"months": [
{
"date": "string",
"published": [
{
"platform": "facebook",
"count": 0
}
],
"views": 0,
"engagement": 0
}
],
"channels": [
{
"_id": "000000000000000000000001",
"name": "string",
"provider": "facebook",
"platform": "facebook",
"status": "connected",
"statisticsStatus": "pending",
"published": 0,
"views": 0,
"engagement": 0,
"followers": 0,
"followersGained": 0
}
],
"topPosts": [
{
"postId": "000000000000000000000001",
"accountId": "000000000000000000000001",
"accountName": "string",
"provider": "facebook",
"platform": "facebook",
"text": "string",
"url": "string",
"publishedAt": "2026-06-15T22:30:00Z",
"views": 0,
"engagement": 0
}
],
"days": [
{
"followers": 0,
"followersGained": 0,
"followersLost": 0,
"views": 0,
"reach": 0,
"engagements": 0,
"clicks": 0,
"watchMinutes": 0,
"websiteClicks": 0,
"calls": 0,
"directionRequests": 0,
"date": "string"
}
]
}
Errors
No errors of its own are known for this endpoint.
Errors nearly every request can meet are listed under Errors.