Skip to main content

Get All Groups

Authentication

Authentication is optional. If authenticated, the response includes membership status for each group.

Response

success
boolean
Indicates whether the request was successful
groups
array
Array of community group objects

Code Example

const response = await fetch('https://api.skillrise.com/api/community/groups', {
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN' // Optional
  }
});

const data = await response.json();
console.log(data.groups);

Response Example

{
  "success": true,
  "groups": [
    {
      "_id": "64a1b2c3d4e5f6789abcdef0",
      "name": "JavaScript Learners",
      "slug": "javascript-learners",
      "description": "A community for everyone learning JavaScript",
      "icon": "🚀",
      "isOfficial": true,
      "memberCount": 1247,
      "postCount": 856,
      "isMember": true
    },
    {
      "_id": "64a1b2c3d4e5f6789abcdef1",
      "name": "Python Developers",
      "slug": "python-developers",
      "description": "Share Python projects, tips, and ask questions",
      "icon": "🐍",
      "isOfficial": false,
      "memberCount": 892,
      "postCount": 543,
      "isMember": false
    }
  ]
}

Create Group

Authentication

This endpoint requires user authentication.
Authorization: Bearer <user_token>

Request Body

name
string
required
Name of the group (1-60 characters, will be trimmed)
description
string
Description of the group (max 200 characters, will be trimmed)
icon
string
Emoji or icon for the group (default: 💬)

Response

success
boolean
Indicates whether the group was created successfully
group
object
The newly created group object (same structure as Get Groups response)
message
string
Error message if success is false

Code Example

const response = await fetch('https://api.skillrise.com/api/community/groups', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_TOKEN'
  },
  body: JSON.stringify({
    name: 'React Enthusiasts',
    description: 'Discuss React patterns, hooks, and best practices',
    icon: '⚛️'
  })
});

const data = await response.json();
console.log(data.group);

Response Example

Success
{
  "success": true,
  "group": {
    "_id": "64a1b2c3d4e5f6789abcdef2",
    "name": "React Enthusiasts",
    "slug": "react-enthusiasts",
    "description": "Discuss React patterns, hooks, and best practices",
    "icon": "⚛️",
    "isOfficial": false,
    "memberCount": 1,
    "postCount": 0,
    "isMember": true
  }
}
Duplicate Name
{
  "success": false,
  "message": "A group with this name already exists"
}

Toggle Group Membership

Authentication

This endpoint requires user authentication.
Authorization: Bearer <user_token>

Path Parameters

groupId
string
required
The unique identifier of the group

Response

success
boolean
Indicates whether the operation was successful
isMember
boolean
New membership status (true if joined, false if left)

Code Example

const groupId = '64a1b2c3d4e5f6789abcdef0';

const response = await fetch(
  `https://api.skillrise.com/api/community/groups/${groupId}/membership`,
  {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_TOKEN'
    }
  }
);

const data = await response.json();
console.log(`Now ${data.isMember ? 'member' : 'not a member'}`);

Response Example

Joined
{
  "success": true,
  "isMember": true
}
Left
{
  "success": true,
  "isMember": false
}

Notes

  • Groups are sorted by official status first, then by member count (descending)
  • The slug is automatically generated from the group name
  • Group creators are automatically made members of the group
  • Toggling membership is idempotent - calling it multiple times toggles between joined/left states
  • Official groups can only be created by platform administrators
  • Group names must be unique (case-insensitive)