Quickstart
Connect to the service, then publish or subscribe.
1. Get a token
Ask your admin for an access token, or use the REST API (see REST API). The token format is AT_<id>_<secret>. The token has permissions: allowed tenants, channels for publish/subscribe, optional IP or origin limits, and an expiry date.
2. Connect
Open a WebSocket to the service URL (e.g. wss://ws.fastpubsub.com/) and pass your token. Server-side clients use the Authorization: Bearer AT_... header; browser clients use the Sec-WebSocket-Protocol subprotocol (see WebSocket API). For gRPC, use the gRPC endpoint and pass the token in metadata.
3. Subscribe (listener)
Send a subscribe message with tenant and channel (or a wildcard pattern). After that you receive messages as WebSocket frames (or gRPC stream messages) for that channel.
4. Publish (writer)
Send a message with tenant, channel, and payload. The service delivers it to all current subscribers of that tenant and channel.
Example flow (pseudo-code):
token = get_token_from_admin_or_rest_api()
connect("wss://ws.fastpubsub.com/", token)
subscribe(tenant="my-tenant", channel="updates")
# receive messages on that channel
publish(tenant="my-tenant", channel="updates", payload="hello")
See Client configuration for tokens and endpoints, API for the exact WebSocket and gRPC formats, and SDKs for client implementation guides.
Same flow in Rust, Java, C#
You can show one example in several languages using the code tabs widget (see Code tabs widget):
#![allow(unused)]
fn main() {
// Get token, connect, subscribe, publish (pseudo)
let token = get_token_from_admin_or_rest_api();
connect_ws("wss://ws.fastpubsub.com/", &token);
subscribe("my-tenant", "updates");
publish("my-tenant", "updates", b"hello");
}
// Get token, connect, subscribe, publish (pseudo)
String token = getTokenFromAdminOrRestApi();
connectWs("wss://ws.fastpubsub.com/", token);
subscribe("my-tenant", "updates");
publish("my-tenant", "updates", "hello".getBytes());
// Get token, connect, subscribe, publish (pseudo)
var token = GetTokenFromAdminOrRestApi();
ConnectWs("wss://ws.fastpubsub.com/", token);
Subscribe("my-tenant", "updates");
Publish("my-tenant", "updates", Encoding.UTF8.GetBytes("hello"));