Realtime
Open a WebSocket and subscribe to channels. You only receive events for resources you're allowed to read; permissions are re-checked per connection.
Connect & subscribe
JavaScript
const ws = new WebSocket(
'wss://base.finiteskills.com/v1/realtime?project=<YOUR_PROJECT_ID>' +
'&channels[]=databases.main.collections.notes.documents'
);
ws.onmessage = (e) => {
const msg = JSON.parse(e.data);
if (msg.type === 'event') console.log(msg.data.event, msg.data.payload);
};
Channels
Available channels
account # the current user session events
databases.{db}.collections.{col}.documents # any document in a collection
databases.{db}.collections.{col}.documents.{id} # one document
files.{bucketId} # file create/delete
broadcast.{name} # client-to-client fan-out
presence.{name} # join/leave/state with a roster
On a broadcast.* channel a client may send
{"type":"broadcast","channel":"broadcast.room","payload":{...}} and every other subscriber
receives it. On a presence.* channel, joins/leaves are announced automatically and a client can
publish its state.