Skip to main content

Get Group Contents

This endpoint retrieves content items that belong to a specific group, identified by the group's id or slug.

Endpoint Details

  • URL: /api/group/contents
  • Method: GET
  • Authentication: Optional (affects content visibility based on user permissions)

Request Parameters

Query Parameters

ParameterTypeRequiredDescription
idintegerNoUnique identifier for the group
slugstringNoURL-friendly identifier for the group
pageintegerNoPage number for pagination (default: 1)
limitintegerNoNumber of items per page (default: 25)
searchstringNoSearch term to filter content items

Note: Either id or slug must be provided.

Response

Success Response

  • Code: 200 OK
  • Content: Paginated list of content items belonging to the group

Response Fields

FieldTypeDescription
itemsarrayArray of content objects
itemsPerPageintegerNumber of items per page
currentPageintegerCurrent page number
totalItemsintegerTotal number of items across all pages
totalPagesintegerTotal number of pages
searchTermstringSearch term used (if any)
hasMorebooleanWhether there are more pages available

Content Object Fields

FieldTypeDescription
idintegerUnique identifier for the content
titlestringTitle of the content
slugstringURL-friendly identifier for the content
descriptionstringDescription of the content (can be null)
descriptionPlainstringPlain text description
descriptionHtmlstringHTML formatted description
likeCountintegerNumber of likes the content has received
commentCountintegerNumber of comments on the content
currentUserHasLikedbooleanWhether the requesting user has liked the content
featuredImagestringFilename of the content's featured image
typestringType of content (video, article, etc.)
videostringPath to video file (for video content)
chatEnabledbooleanWhether chat is enabled for this content
visibilitystringPrivacy setting of the content
publishedDatestringISO timestamp of when the content was published
featuredbooleanWhether the content is featured
createdAtstringISO timestamp of when the content was created
updatedAtstringISO timestamp of when the content was last updated
PlatformIdintegerID of the platform the content belongs to
UserIdintegerID of the user who created the content
GroupsarrayArray of groups the content belongs to
UserobjectInformation about the content creator
CollectionsarrayArray of collections the content belongs to

Example Response

{
"items": [
{
"id": 4481,
"title": "How To Protect Your Kingdom Content - Masterclass with Peter Nieves",
"slug": "How-To-Protect-Your-Kingdom-Content-Masterclass-with-Peter-Nieves",
"description": null,
"descriptionPlain": "",
"descriptionHtml": "",
"likeCount": 2,
"commentCount": 0,
"currentUserHasLiked": false,
"featuredImage": "1649083201463.png",
"type": "video",
"ingestEndpoint": null,
"contentURI": null,
"video": "videos/1649082625439.mp4",
"chatEnabled": false,
"options": null,
"visibility": "premium",
"expireDate": null,
"publishedDate": "2022-03-17T04:00:00.000Z",
"transcodingDataSJ": null,
"featured": false,
"createdAt": "2022-04-04T14:38:15.000Z",
"updatedAt": "2022-04-04T14:40:09.000Z",
"PlatformId": 36,
"UserId": 6604,
"Groups": [],
"User": {},
"Collections": []
}
],
"itemsPerPage": 25,
"currentPage": 1,
"totalItems": 78,
"totalPages": 4,
"searchTerm": "",
"hasMore": true
}

Error Responses

  • Code: 400 Bad Request

    • Content: { error: "Error message" }
  • Code: 403 Forbidden

    • Content: "Insufficient role"

Notes

  • Content visibility depends on the user's role and the group's visibility settings.
  • For private groups, only members can view the content.
  • The response is paginated, with a default of 25 items per page.

Code Examples

JavaScript

const getGroupContents = async (id, page = 1, limit = 25, search = "") => {
try {
const queryParams = new URLSearchParams({
id,
page,
limit,
...(search && { search })
}).toString();

const response = await fetch(`https://api.tribesocial.io/api/group/contents?${queryParams}`, {
method: "GET",
headers: {
Authorization: "Bearer YOUR_TOKEN_HERE",
"Content-Type": "application/json"
}
});

if (response.status === 403) {
throw new Error("Insufficient permissions to access this group");
}

if (!response.ok) {
throw new Error("Failed to fetch group contents");
}

const contents = await response.json();
return contents;
} catch (error) {
console.error("Error fetching group contents:", error);
throw error;
}
};