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
| Field | Type | Description |
|---|---|---|
| id | integer | Unique identifier for the group |
| name | string | Name of the group |
| description | string | Description of the group (can be null) |
| slug | string | URL-friendly identifier for the group |
| coverImage | string | Filename of the group's cover image |
| visibility | string | Privacy setting of the group (public, private, etc.) |
| purchaseLink | string | Optional link for purchasing access to the group |
| createdAt | string | ISO timestamp of when the group was created |
| updatedAt | string | ISO timestamp of when the group was last updated |
| PlatformId | integer | ID of the platform the group belongs to |
| groupCreatorId | integer | ID of the user who created the group |
| userCount | integer | Number of users in the group |
| isMember | boolean | Whether the requesting user is a member of the group |
| Users | array | Array 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;
}
};
Related Endpoints
- Get Group by Slug - Get detailed information about a specific group
- Get Groups by Platform ID - Get all groups for a specific platform