Skip to main content

Get My Groups

This endpoint retrieves all groups in which the requesting user is a member or admin.

Endpoint Details

  • URL: /api/my-groups (Alias: /api/user/groups)
  • Method: GET
  • Authentication: Required (any role)

Request Parameters

No URL parameters are required for this endpoint.

Response

Success Response

  • Code: 200 OK
  • Content: Array of group objects

Response Fields

FieldTypeDescription
idintegerUnique identifier for the group
namestringName of the group
descriptionstringDescription of the group (can be null)
slugstringURL-friendly identifier for the group
coverImagestringFilename of the group's cover image
visibilitystringPrivacy setting of the group (public, private, etc.)
purchaseLinkstringOptional link for purchasing access to the group
createdAtstringISO timestamp of when the group was created
updatedAtstringISO timestamp of when the group was last updated
PlatformIdintegerID of the platform the group belongs to
groupCreatorIdintegerID of the user who created the group
userCountintegerNumber of users in the group
isMemberbooleanWhether the requesting user is a member of the group
UsersarrayArray of user objects associated with the group

Example Response

[
{
"id": 134,
"name": "private group",
"description": null,
"slug": "private-group",
"coverImage": "1652800675986.jpg",
"visibility": "private",
"purchaseLink": null,
"createdAt": "2022-05-17T04:51:15.000Z",
"updatedAt": "2022-05-17T15:18:06.000Z",
"PlatformId": 36,
"groupCreatorId": 9846,
"userCount": 3,
"isMember": true,
"Users": [
{
"id": 9846,
"UserGroup": {
"role": "admin",
"createdAt": "2022-05-17T04:51:15.000Z",
"updatedAt": "2022-05-17T04:51:15.000Z",
"GroupId": 134,
"UserId": 9846
}
}
]
}
]

Error Response

  • Code: 400 Bad Request
  • Content: { error: "Error message" }

Code Examples

JavaScript

const fetchMyGroups = async () => {
try {
const response = await fetch("https://api.tribesocial.io/api/my-groups", {
method: "GET",
headers: {
Authorization: "Bearer YOUR_TOKEN_HERE",
"Content-Type": "application/json"
}
});

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

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