Skip to main content

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

ParameterTypeRequiredDescription
idintegerNoUnique identifier for the group
slugstringNoURL-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

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
UsersarrayArray of user objects associated with the group
myRolestringRole of the requesting user in the group (if authenticated)
userCountintegerNumber of users in the group
requestsarrayArray of pending access requests (for admins)
hasRequestedAccessbooleanWhether 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" }
  • Code: 404 Not Found

    • Content: "Group not found"

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