Core Client APIs Overview
Navigate the Erebus PubSub client APIs organized by functionality
Core Client APIs Overview
The Erebus Core SDK provides comprehensive APIs for real-time messaging, presence tracking, and message history. This overview helps you navigate to the specific functionality you need.
📚 API Documentation Structure
Our API documentation is organized into focused sections for easier learning and reference:
Section | Coverage | When to Use |
---|---|---|
Getting Started | Basic APIs + working examples | First-time SDK users |
Messaging | Publish/subscribe + history | Building real-time features |
Connection Management | Lifecycle + error handling | Production apps |
Presence Tracking | User awareness APIs | Social features |
Types Reference | TypeScript definitions | Type-safe development |
🚀 Quick Navigation
New to Erebus?
Start with Getting Started with APIs for a practical walkthrough with working examples.
Building Real-Time Features?
Go to Messaging APIs for publish/subscribe patterns and message history.
Need Robust Connections?
Check Connection Management for lifecycle management and error handling.
Adding Social Features?
Visit Presence Tracking for user awareness and online status.
Working with TypeScript?
Reference Types Reference for complete type definitions.
💡 Quick Examples
Basic Usage
import { ErebusClient, ErebusClientState } from "@erebus-sh/sdk/client";
const client = ErebusClient.createClient({
client: ErebusClientState.PubSub,
authBaseUrl: "https://your-auth.com"
});
client.joinChannel("my-app");
await client.connect();
await client.subscribe("notifications", console.log);
await client.publish("notifications", "Hello!");
With Presence
// Track user activity
await client.onPresence("chat:room", (presence) => {
console.log(`${presence.clientId} is ${presence.status}`);
});
With History
// Catch up on missed messages
const history = await client.getHistory("chat:room", {
limit: 50,
direction: "backward"
});
With Type Safety
import { ErebusPubSubSchemas } from "@erebus-sh/sdk/client";
import { z } from "zod";
const schemas = { chat: z.object({ text: z.string() }) };
const typed = new ErebusPubSubSchemas(client, schemas);
await typed.subscribe("chat", "room", (msg) => {
console.log(msg.payload.text); // ✅ Fully typed
});
🔗 Related Resources
- Complete Examples - Working applications
- Quick Reference - API cheat sheet
- Schema Facade - Type-safe messaging
- Message History Guide - Advanced pagination patterns
📖 Detailed API Documentation
The API documentation has been reorganized into focused sections for better navigation:
🏁 Getting Started with APIs
- Complete working example with auth server setup
- Step-by-step walkthrough of core APIs
- Common use case patterns for chat, notifications, collaboration
📡 Messaging APIs
- Publish/subscribe patterns with examples
- Advanced subscription options and callbacks
- Message history with pagination and iterators
🔌 Connection Management
- Connection lifecycle and state monitoring
- Error handling patterns and recovery strategies
- Production best practices and monitoring
👥 Presence Tracking
- User awareness APIs for online/offline status
- Advanced presence patterns for typing indicators
- Multi-topic presence management
📋 Types Reference
- Complete TypeScript definitions for all APIs
- Interface documentation with usage examples
- Type guards and utility types
🎯 Quick API Examples
Basic Publish/Subscribe
// Simple messaging
await client.subscribe("notifications", (msg) => {
console.log("📩", msg.payload);
});
await client.publish("notifications", "Hello World!");
With Acknowledgments
// Reliable delivery
await client.publishWithAck(
"alerts",
"System maintenance starting",
(ack) => console.log("Delivered:", ack.success)
);
With Presence
// Track user activity
await client.onPresence("chat:room", (presence) => {
updateUserList(presence.clientId, presence.status);
});
With History
// Load message history
const history = await client.getHistory("chat:room", { limit: 50 });
history.items.forEach(displayMessage);
🔗 Quick Links
Resource | Description |
---|---|
Getting Started | Complete walkthrough with examples |
Message History | Advanced pagination guide |
Schema Validation | Type-safe messaging |
Examples | Working applications |