@hastenr/chatapi-sdk
v0.1.5
Published
Official ChatAPI TypeScript SDK for real-time messaging
Maintainers
Readme
ChatAPI TypeScript SDK
The official TypeScript SDK for ChatAPI - a lightweight, multitenant chat service with real-time messaging capabilities.
Installation
npm install @hastenr/chatapi-sdkQuick Start
import { ChatAPI } from '@hastenr/chatapi-sdk';
// Initialize
const chat = new ChatAPI({
baseURL: 'https://api.chatapi.com',
apiKey: 'your-api-key',
userId: 'current-user-id'
});
// Connect
await chat.connect();
// Listen for messages
chat.on('message', (event) => {
console.log('New message:', event.content);
});
// Send a message
await chat.messages.send('room_123', 'Hello, world!');Features
- ✅ Type-Safe: Full TypeScript support
- ✅ Real-Time: WebSocket with auto-reconnection
- ✅ REST API: Complete HTTP client
- ✅ Error Handling: Comprehensive error types
- ✅ Framework Agnostic: Works anywhere
API Overview
Rooms
const room = await chat.rooms.create({
type: 'group',
members: ['alice', 'bob'],
name: 'Team Chat'
});Messages
await chat.messages.send('room_123', 'Hello!');
const messages = await chat.messages.get('room_123', { limit: 50 });Real-Time Events
chat.on('message', (event) => console.log(event));
chat.on('presence.update', (event) => console.log(event));Documentation
See the ChatAPI Documentation for complete API reference and guides.
License
MIT License - see LICENSE file for details.
