Skip to Content
Foru.ms
Foru.ms logo

Announcing the Official Foru.ms JavaScript/TypeScript SDK

We are excited to announce the release of the official JavaScript/TypeScript SDK for Foru.ms . This new SDK allows you to build powerful community features directly into your application with ease.

It is fully typed and provides a comprehensive, easy-to-use interface to the Foru.ms API.

Installation

npm install @foru-ms/sdk # or yarn add @foru-ms/sdk # or pnpm add @foru-ms/sdk

Setup & Initialization

import { ForumClient } from '@foru-ms/sdk'; const client = new ForumClient({ apiKey: 'your_api_key', // baseUrl: 'https://api.foru.ms/v1' // Optional }); // Set an authentication token (JWT) for user-scoped requests client.setToken('user_jwt_token');

API Reference

Auth (client.auth)

Threads (client.threads)

Posts (client.posts)

Users (client.users)

Tags (client.tags)

Notifications (client.notifications)

Search (client.search)

Webhooks (client.webhooks)

Stats (client.stats)

Integrations (client.integrations)

Private Messages (client.privateMessages)

Reports (client.reports)

Roles (client.roles)

SSO (client.sso)

Types

Import all available interfaces and types directly from the package:

import { // Auth Types RegisterPayload, User, LoginResponse, // Thread Types Thread, CreateThreadPayload, UpdateThreadPayload, ThreadListResponse, ThreadFilter, // Post Types Post, CreatePostPayload, UpdatePostPayload, PostListResponse, // Tag Types Tag, TagListResponse, // User Types UserListResponse, // Notification Types Notification, NotificationListResponse, // Search Types SearchResponse, // Webhook Types Webhook, WebhookListResponse, // Stats Types StatsResponse, // Integration Types Integration, IntegrationListResponse, // Private Message Types PrivateMessage, PrivateMessageListResponse, // Report Types Report, ReportListResponse, // Role Types Role, RoleListResponse, // SSO Types SSOProvider, SSOProviderListResponse, // Utility Types PaginatedResponse, InteractionType } from '@foru-ms/sdk';

Error Handling

All methods return a Promise. If the API returns a non-200 status, the Promise rejects with an Error object containing the server message.

try { await client.threads.create({ ... }); } catch (err: any) { console.error("Error creating thread:", err.message); }

License

MIT