Skip to main content

Overview

Communities are parent groups that contain linked subgroups. They use the w:g2 IQ namespace for mutations and MEX (GraphQL) for metadata queries. This guide covers creating communities, linking and unlinking subgroups, querying subgroup metadata, and identifying group types within a community hierarchy.

Accessing the Community API

All community operations are accessed through the community() method:
See Community API reference for the full API.

Creating a community

By default, create_general_chat is true, so a general chat subgroup is created alongside the community. See Community API reference for details.

Community creation options

Customize the community with CreateCommunityOptions:
If a description is provided, it is set via a follow-up IQ after creation — the group create stanza does not support inline descriptions for communities.

Deactivating a community

Deactivate (delete) a community. Subgroups are unlinked but not deleted:
See Community API reference for details.

Managing subgroups

Link existing groups as subgroups of a community:
See Community API reference for details. Unlink subgroups from a community:
When remove_orphan_members is true, members who are only in the community through the unlinked subgroups are removed from the community. See Community API reference for details.

Join a subgroup

Join a linked subgroup via the parent community:
See Community API reference for details.

Querying community information

List subgroups

Fetch all subgroups of a community via MEX (GraphQL):
See Community API reference for details.

Get subgroup participant counts

Fetch participant counts per subgroup without fetching full subgroup details:
See Community API reference for details.

Query linked group metadata

Query a specific linked subgroup’s metadata from the parent community:
See Community API reference for details.

Get all participants across subgroups

Fetch all participants across all linked groups of a community:
See Community API reference for details.

Identifying group types

Use the group_type function to classify a group within the community hierarchy:
The classification is based on these GroupMetadata fields: See Groups API reference for all GroupMetadata fields.

Error handling

Community mutations return anyhow::Error, while MEX-based queries (get_subgroups, get_subgroup_participant_counts) return MexError:

Next steps