Get Group
This endpoint retrieves detailed information about a specific group using its id or slug.
Endpoint Details
- URL:
/api/group - Method:
GET - Authentication: Optional (affects response content 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 |
Note: Either id or slug must be provided.
Response
Success Response
- Code:
200 OK - Content: Group object with detailed information
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 |
| Users | array | Array of user objects associated with the group |
| myRole | string | Role of the requesting user in the group (if authenticated) |
| userCount | integer | Number of users in the group |
| requests | array | Array of pending access requests (for admins) |
| hasRequestedAccess | boolean | Whether the requesting user has requested access |
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,
"Users": [
{
"id": 9846,
"name": "Andrew njoo",
"photoUrl": "1653064636313.jpeg",
"UserGroup": {
"role": "admin",
"createdAt": "2022-05-17T04:51:15.000Z"
}
}
],
"myRole": "admin",
"userCount": 1,
"requests": [],
"hasRequestedAccess": false
}
Error Responses
-
Code:
400 Bad Request- Content:
{ error: "Error message" }
- Content:
-
Code:
404 Not Found- Content:
"Group not found"
- Content:
Notes
- The response will include different information based on the authentication status and role of the requesting user.
- For private groups, non-members will see limited information.
- Group admins will see additional information such as pending access requests.
Code Examples
JavaScript
const getGroupBySlug = async slug => {
try {
const response = await fetch(`https://api.tribesocial.io/api/group/${slug}`, {
method: "GET",
headers: {
Authorization: "Bearer YOUR_TOKEN_HERE",
"Content-Type": "application/json"
}
});
if (response.status === 404) {
throw new Error("Group not found");
}
if (!response.ok) {
throw new Error("Failed to fetch group");
}
const group = await response.json();
return group;
} catch (error) {
console.error("Error fetching group:", error);
throw error;
}
};
Related Endpoints
- Get My Groups - Get all groups where the user is a member
- Get Group Contents - Get content items belonging to a group