Getting Started
Telpun offers a real-time pub/sub API over SSE (Server-Sent Events). It’s simple to use both on the frontend and backend.
Authentication
Clients authenticate using a public API key or a short-lived JWT token:
const telpun = new Telpun("YOUR_API_KEY");
Or if using JWT:
const telpun = new Telpun("YOUR_JWT_TOKEN");
Tokens are issued from your backend and tied to a project or user identity.
Subscribing to Events
Listen to a topic from your frontend:
telpun.subscribe("chat:room:123", (data) => {
console.log("Received:", data);
});
Each topic acts as a pub/sub channel.
Emitting Events (Backend)
Send events from your backend via a simple HTTP POST:
POST /emit
Content-Type: application/json
{
"channel": "chat:room:123",
"data": {
"text": "Hello from server"
}
}
Delivery Quota
Each message delivered to one client counts as one delivery. For example, sending to 5 clients = 5 deliveries.
- Your quota resets on the 1st of each month (UTC)
- Quota is shared across all projects under your account
- Check your usage via the dashboard or upcoming API endpoint
Error Handling
If the event can't be delivered or quota is exceeded, Telpun will respond with HTTP error codes (e.g., 429 for quota exceeded).