Skip to main content

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

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 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

FieldTypeDescription
itemsarrayArray of collection 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

Collection Object Fields

FieldTypeDescription
idintegerUnique identifier for the collection
namestringName of the collection
slugstringURL-friendly identifier for the collection
descriptionstringDescription of the collection (can be null)
featuredImagestringFilename of the collection's featured image
visibilitystringPrivacy setting of the collection
createdAtstringISO timestamp of when the collection was created
updatedAtstringISO timestamp of when the collection was updated
PlatformIdintegerID of the platform the collection belongs to
UserIdintegerID of the user who created the collection
contentCountintegerNumber of content items in the collection
GroupsarrayArray 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" }
  • Code: 403 Forbidden

    • Content: "Insufficient role"

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;
}
};