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
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | integer | No | Unique identifier for the group |
| slug | string | No | URL-friendly identifier for the group |
| page | integer | No | Page number for pagination (default: 1) |
| limit | integer | No | Number of items per page (default: 25) |
| search | string | No | Search 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
| Field | Type | Description |
|---|---|---|
| items | array | Array of content objects |
| itemsPerPage | integer | Number of items per page |
| currentPage | integer | Current page number |
| totalItems | integer | Total number of items across all pages |
| totalPages | integer | Total number of pages |
| searchTerm | string | Search term used (if any) |
| hasMore | boolean | Whether there are more pages available |
Content Object Fields
| Field | Type | Description |
|---|---|---|
| id | integer | Unique identifier for the content |
| title | string | Title of the content |
| slug | string | URL-friendly identifier for the content |
| description | string | Description of the content (can be null) |
| descriptionPlain | string | Plain text description |
| descriptionHtml | string | HTML formatted description |
| likeCount | integer | Number of likes the content has received |
| commentCount | integer | Number of comments on the content |
| currentUserHasLiked | boolean | Whether the requesting user has liked the content |
| featuredImage | string | Filename of the content's featured image |
| type | string | Type of content (video, article, etc.) |
| video | string | Path to video file (for video content) |
| chatEnabled | boolean | Whether chat is enabled for this content |
| visibility | string | Privacy setting of the content |
| publishedDate | string | ISO timestamp of when the content was published |
| featured | boolean | Whether the content is featured |
| createdAt | string | ISO timestamp of when the content was created |
| updatedAt | string | ISO timestamp of when the content was last updated |
| PlatformId | integer | ID of the platform the content belongs to |
| UserId | integer | ID of the user who created the content |
| Groups | array | Array of groups the content belongs to |
| User | object | Information about the content creator |
| Collections | array | Array 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" }
- Content:
-
Code:
403 Forbidden- Content:
"Insufficient role"
- Content:
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;
}
};
Related Endpoints
- Get Group by Slug - Get detailed information about a specific group
- Get Group Collections - Get collections belonging to a group