Get Group Collections
This endpoint retrieves collections that belong to a specific group, identified by the group's id or slug.
Endpoint Details
- URL:
/api/group/collections - Method:
GET - Authentication: Optional (affects collection 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 collections |
Note: Either id or slug must be provided.
Response
Success Response
- Code:
200 OK - Content: Paginated list of collections belonging to the group
Response Fields
| Field | Type | Description |
|---|---|---|
| items | array | Array of collection 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 |
Collection Object Fields
| Field | Type | Description |
|---|---|---|
| id | integer | Unique identifier for the collection |
| name | string | Name of the collection |
| slug | string | URL-friendly identifier for the collection |
| description | string | Description of the collection (can be null) |
| featuredImage | string | Filename of the collection's featured image |
| visibility | string | Privacy setting of the collection |
| createdAt | string | ISO timestamp of when the collection was created |
| updatedAt | string | ISO timestamp of when the collection was updated |
| PlatformId | integer | ID of the platform the collection belongs to |
| UserId | integer | ID of the user who created the collection |
| contentCount | integer | Number of content items in the collection |
| Groups | array | Array of groups the collection belongs to |
Example Response
{
"items": [
{
"id": 245,
"name": "Marketing Strategies",
"slug": "marketing-strategies",
"description": "A collection of marketing strategy resources",
"featuredImage": "1649083201463.png",
"visibility": "premium",
"createdAt": "2022-04-04T14:38:15.000Z",
"updatedAt": "2022-04-04T14:40:09.000Z",
"PlatformId": 36,
"UserId": 6604,
"contentCount": 12,
"Groups": [
{
"id": 134,
"name": "private group",
"slug": "private-group"
}
]
}
],
"itemsPerPage": 25,
"currentPage": 1,
"totalItems": 5,
"totalPages": 1,
"searchTerm": "",
"hasMore": false
}
Error Responses
-
Code:
400 Bad Request- Content:
{ error: "Error message" }
- Content:
-
Code:
403 Forbidden- Content:
"Insufficient role"
- Content:
Notes
- Collection visibility depends on the user's role and the group's visibility settings.
- For private groups, only members can view the collections.
- The response is paginated, with a default of 25 items per page.
Code Examples
JavaScript
const getGroupCollections = 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/collections?${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 collections");
}
const collections = await response.json();
return collections;
} catch (error) {
console.error("Error fetching group collections:", error);
throw error;
}
};
Related Endpoints
- Get Group by Slug - Get detailed information about a specific group
- Get Group Contents - Get content items belonging to a group