Metered Realtime Messaging
Bi-directional, low-latency messaging over WebSockets. One protocol covers WebRTC signalling, AI agent communication, live presence and chat, IoT telemetry, and collaborative applications.
your client ⇄ Metered Realtime Messaging ⇄ your client / your backend
Two ways to use it
Using JavaScript or TypeScript? Start with the @metered-ca/peer SDK — it handles framing, ack correlation, reconnect, perfect-negotiation WebRTC, and TURN injection for you. Most JS apps ship in ~30 lines of code.
Using any other stack (Go, Python, Java, Swift, Kotlin, Rust, Unity), or want the underlying details? The Protocol Reference and Use Case Guides below cover the raw WebSocket path. The SDK and raw-WS clients interoperate.
What it gives you
- Channels — publish/subscribe with wildcard routing (
app_xyz/*,room-*) - Direct messages — peer-to-peer send by
peerId, no channel required - Presence — automatic join/leave events with optional per-peer metadata (
userId,username,profilePic, anything you want) - JWT-minted credentials — your backend authorizes who can do what, for how long
- REST API — mint tokens, list peers, server-side publish, kick peers, read usage
- Built-in TURN integration — embed Metered TURN credentials in the JWT and your peers get them at connect time
Five things you can build with it
| Use case | Why this fits |
|---|---|
| WebRTC signalling | SDP / ICE exchange + automatic TURN credentials in the same connection |
| AI agent communication | Multi-agent coordination, agent-to-user streams, tool-call relays |
| Live presence & chat | Classroom, proctoring, livestream chat — built-in presence + metadata |
| IoT telemetry & control | Camera events, vehicle telematics, device commands — MQTT-style pub/sub over WS |
| Collaborative apps | Cursors, live dashboards, shared editing state |
Each of these has a dedicated Use Case Guide with end-to-end code.
How it relates to other Metered products
- TURN Server — for WebRTC media relay. Realtime Messaging is the signalling layer that goes with TURN; one Metered account can use both, and your sk_ key can mint connect-tokens that ship TURN credentials inline.
- Global Cloud SFU — for selective forwarding of media streams. Realtime Messaging is the signalling + control plane; the SFU is the media plane.
- Video SDK — wraps both above for high-level video-call UX. Use Realtime Messaging directly when you want lower-level control over the wire protocol.
Where to start
- Using JavaScript / TypeScript? → JavaScript SDK (
npm install @metered-ca/peer) - New to the product, want the lower-level path? → Quickstart (raw WebSocket, ~30 lines)
- Building a WebRTC app with the SDK? → SDK: WebRTC Video Call
- Building a WebRTC app from any stack? → WebRTC Signalling guide
- Going to production? → SDK: Reconnect Best Practices — required reading
- Just want the reference? → Wire Format + REST API