LatteStream®
Quick Start
Getting Started
Building Custom SDKs
SDKs & Libraries
JavaScript/TypeScript
Node.js / Bun / Deno
Python
Go
PHP
API Reference
WebSocket API
REST API
Webhooks
Authentication
Complete reference for all LatteStream APIs and protocols
This section provides comprehensive documentation for all LatteStream APIs, protocols, and interfaces. Whether you're building with our SDKs or integrating directly with our APIs, you'll find everything you need here.
LatteStream provides multiple API surfaces for different use cases:
The WebSocket API enables real-time communication between clients and the LatteStream service.
wss://ws-{cluster}.lattestream.com/app/{app-key}
View WebSocket API Documentation →
The REST API allows server-side applications to trigger events, manage channels, and retrieve information.
https://api-{cluster}.lattestream.com
All REST API requests require authentication using your Master Key:
Authorization: Bearer {master-key} Content-Type: application/json
POST /apps/{app-id}/events - Trigger eventsGET /apps/{app-id}/channels - List channelsGET /apps/{app-id}/channels/{channel} - Get channel infoGET /apps/{app-id}/channels/{channel}/users - Get presence usersWebhooks provide server-side notifications for connection events, channel lifecycle, and user presence changes.
connection_established, connection_disconnectedchannel_occupied, channel_vacatedmember_added, member_removedclient_event (for presence channels)All webhooks are signed with HMAC-SHA256 for authenticity verification.
LatteStream uses a multi-layered authentication system to secure your applications.
View Authentication Documentation →
LatteStream implements rate limiting to ensure fair usage and system stability.
| Plan | Concurrent Connections | Channels per Connection |
|---|---|---|
| Free | 100 | 10 |
| Pro | 1,000 | 50 |
| Business | 10,000 | 100 |
| Enterprise | Custom | Custom |
| Endpoint Category | Rate Limit | Burst Limit |
|---|---|---|
| Event Triggering | 1,000/min | 100/sec |
| Channel Info | 500/min | 50/sec |
| Authentication | 2,000/min | 200/sec |
LatteStream operates in multiple regions for optimal performance:
us-east-1 - US East (Virginia) - Defaultus-west-2 - US West (Oregon)eu-west-1 - Europe (Ireland)ap-southeast-1 - Asia Pacific (Singapore)ap-northeast-1 - Asia Pacific (Tokyo)Choose the cluster closest to your users for best performance:
// Client SDK const lattestream = new LatteStream('your-app-key', { cluster: 'eu-west-1', }); // Server SDK const lattestream = new LatteStreamServer('app-key', 'master-key', { cluster: 'eu-west-1', });
Official SDKs are available for multiple languages and frameworks:
| Code | Name | Description |
|---|---|---|
| 4001 | Application does not exist | Invalid app key |
| 4004 | Application over quota | Connection limit exceeded |
| 4005 | Path not found | Invalid WebSocket path |
| 4006 | Invalid version string | Unsupported protocol version |
| 4007 | Unsupported protocol version | Use supported version |
| 4008 | No protocol version supplied | Missing version in connection |
| Code | Description | Common Causes |
|---|---|---|
| 400 | Bad Request | Invalid JSON, missing parameters |
| 401 | Unauthorized | Invalid or missing Master Key |
| 403 | Forbidden | Insufficient permissions |
| 404 | Not Found | Invalid app ID or channel |
| 413 | Payload Too Large | Message exceeds size limit |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Internal Server Error | Service issue |
All WebSocket messages follow a standardized JSON format:
{ "event": "event_name", "channel": "channel_name", "data": "json_string" }
WebSocket connections progress through these states:
connecting - Establishing connectionconnected - Successfully connecteddisconnected - Connection lostreconnecting - Attempting to reconnectfailed - Connection failed permanentlySubscribe to Channel
const channel = lattestream.subscribe('my-channel'); channel.bind('my-event', (data) => console.log(data));
Trigger Event from Server
await lattestream.trigger('my-channel', 'my-event', { message: 'Hello' });
Authenticate Private Channel
app.post('/lattestream/auth', (req, res) => { const auth = lattestream.authenticate( req.body.socket_id, req.body.channel_name ); res.json(auth); });
# Required LATTESTREAM_APP_KEY=app_1234567890abcdef LATTESTREAM_MASTER_KEY=master_1234567890abcdef # Optional LATTESTREAM_CLUSTER=us-east-1 LATTESTREAM_WEBHOOK_SECRET=webhook_secret_key LATTESTREAM_ENABLE_LOGGING=true
Need help? Start with our Getting Started guide or explore specific API documentation above.