Edit

Communities, notifications and groups

Communities

Communities are forums, each optionally tied to a course. Standard plan or higher on LearnHouse Cloud.

MethodEndpointReturnsAuth
communities.list(orgId, { page, limit })GET /api/v1/communities/org/{org_id}/page/{page}/limit/{limit}Community[]Anyone, API token
communities.listAll(orgId, { pageSize })The same, page after pageasync iterator of CommunityAnyone, API token
communities.get(uuid)GET /api/v1/communities/{community_uuid}CommunityAnyone (public)
communities.getForCourse(courseUuid)GET /api/v1/communities/course/{course_uuid}Community | nullAnyone (public)
communities.summary(orgId)GET /api/v1/communities/org/{org_id}/summaryCommunitySummary[]: counts and last activityAnyone, API token
communities.activity(orgId)GET /api/v1/communities/org/{org_id}/activityCommunityActivity[]Admins, API token
communities.listDiscussions(uuid, { sortBy, label, page, limit })GET /api/v1/communities/{community_uuid}/discussionsDiscussion[]Anyone (public)
communities.createDiscussion(uuid, { title, content, label, emoji })POST /api/v1/communities/{community_uuid}/discussionsDiscussionWithVoteSession

sortBy is recent (default), upvotes or hot; label is a label id from discussions.labels(). Pages default to 20 communities or 10 discussions.

Discussions

MethodEndpointReturnsAuth
discussions.labels()GET /api/v1/discussions/labelsDiscussionLabel[]Anyone
discussions.get(uuid)GET /api/v1/discussions/{discussion_uuid}Discussion (counts, has_voted)Anyone (public)
discussions.update(uuid, { title, content, label, emoji })PUT /api/v1/discussions/{discussion_uuid}DiscussionWithVoteSession (author, moderators)
discussions.delete(uuid)DELETE /api/v1/discussions/{discussion_uuid}objectSession (author, moderators)
discussions.listComments(uuid, { page, limit })GET /api/v1/discussions/{discussion_uuid}/commentsDiscussionComment[], oldest firstAnyone (public)
discussions.countComments(uuid)GET /api/v1/discussions/{discussion_uuid}/comments/count{ count }Anyone (public)
discussions.reply(uuid, content)POST /api/v1/discussions/{discussion_uuid}/commentsDiscussionCommentSession
discussions.updateComment(commentUuid, content)PUT /api/v1/comments/{comment_uuid}DiscussionCommentSession (author)
discussions.deleteComment(commentUuid)DELETE /api/v1/comments/{comment_uuid}objectSession (author, moderators)
discussions.vote(uuid) / unvote(uuid)POST / DELETE /api/v1/discussions/{discussion_uuid}/voteDiscussionVote / objectSession
discussions.voteComment(commentUuid) / unvoteComment(commentUuid)POST / DELETE /api/v1/comments/{comment_uuid}/voteDiscussionCommentVote / objectSession
discussions.listReactions(uuid)GET /api/v1/discussions/{discussion_uuid}/reactionsDiscussionReaction[] (emoji, count, has_reacted)Anyone (public)
discussions.react(uuid, emoji, { active })POST /api/v1/discussions/{discussion_uuid}/reactions{ action: 'added' | 'removed' }Session
const community = await lh.communities.getForCourse('course_…')
if (community) {
  const discussion = await lh.communities.createDiscussion(community.community_uuid, {
    title: 'Stuck on exercise 3',
    content: 'The loop never ends. What am I missing?',
  })
  await lh.discussions.reply(discussion.discussion_uuid, 'Check the exit condition.')
  await lh.discussions.react(discussion.discussion_uuid, '👀')
}
  • A new discussion comes with its author's upvote (upvote_count: 1). A second upvote by the same user answers 400; unvote() first.
  • react() toggles the emoji; pass active: true or false to set it instead.
  • Posts are checked against the community's moderation words (400 when a post is blocked). Locked discussions refuse replies (403).

Notifications

The signed-in user's inbox, unread counts, preferences and push devices. Auth: session only.

MethodEndpointReturns
notifications.list(options)GET /api/v1/notificationsNotificationPage (items, next_cursor)
notifications.listAll(options)The same, following next_cursorasync iterator of Notification
notifications.unreadCount({ orgId, audience })GET /api/v1/notifications/unread_countNotificationUnread
notifications.counts({ orgId })GET /api/v1/notifications/counts{ personal, admin } unread counts
notifications.markRead({ uuids } | { all: true, … })POST /api/v1/notifications/readNotificationChange
notifications.markOneRead(uuid) / markOneUnread(uuid)POST /api/v1/notifications/{uuid}/read / unreadNotificationChange
notifications.archive(uuid) / unarchive(uuid)POST /api/v1/notifications/{uuid}/archive / unarchiveNotificationChange
notifications.delete(uuid)DELETE /api/v1/notifications/{uuid}{ deleted }
notifications.getPreferences()GET /api/v1/notifications/preferencesobject
notifications.updatePreferences(input)PUT /api/v1/notifications/preferencesobject
notifications.listDevices()GET /api/v1/notifications/devicesthe user's push devices
notifications.registerDevice({ token, platform, orgId, deviceName, appVersion })POST /api/v1/notifications/devices
notifications.unregisterDevice(token)POST /api/v1/notifications/devices/unregister

list() options: orgId, unreadOnly, category (messages, assignments, courses, live, community, groups, …), audience (personal by default, admin, all), archived, type, important, q (search), cursor and limit (up to 100). Every change answers with fresh unread counts, so a badge can update without another call.

// An inbox with a badge.
const { unread_count } = await lh.notifications.unreadCount({ orgId: org.id! })
for await (const n of lh.notifications.listAll({ orgId: org.id!, unreadOnly: true })) {
  console.log(n.title, n.path)
}
await lh.notifications.markRead({ all: true, orgId: org.id! })

A notification's path is where it points in the LearnHouse app (/course/…/activity/…), and data carries the ids it is about. For push on phones see React Native.

User groups

MethodEndpointReturnsAuth
usergroups.listMine(orgId)GET /api/v1/usergroups/org/{org_id}/mineUserGroupMembership: member_of, managesSession
usergroups.join(code)POST /api/v1/usergroups/join{ status: 'joined' | 'already_member', usergroup_uuid, name, expires_at }Session

Join codes are created by group managers in the dashboard. An unknown or expired code answers 404, a code used up 409, and a user who isn't a member of the organization yet 403. Managing groups from a server is in the Admin API.

Messaging (direct messages, the /messaging routes) is not wrapped yet; call it with the typed lh.GET / lh.POST.