Index of every page on this site: llms.txt
Skip to content

Realtime

The browser receives a short-lived, single-use ticket. It never receives the long-lived Bearer credential.

  1. Your server calls realtime.tickets.create with {} or the browser's exact registered Origin.
  2. The browser opens socketUrl with gscdump.v1 and the ticket as its two WebSocket subprotocols.
  3. The client applies each durable event before it advances its cursor or acknowledges the event.
  4. If replay is unsafe, the client runs a full authoritative resync before it reports fresh state.

createGscdumpRealtimeV1Client owns ticket rotation, replay, cumulative ACKs, heartbeat checks, reconnect backoff, and the 15-minute connection lifetime. You provide the application-specific effects:

import {
  createGscdumpRealtimeV1Client,
  createGscdumpV1Client,
} from '@gscdump/sdk/v1'

const http = createGscdumpV1Client({
  credential: () => process.env.GSCDUMP_API_KEY!,
})

const realtime = createGscdumpRealtimeV1Client({
  ticketProvider: () => http.createRealtimeTicket({ body: {} }),
  // Implement these hooks in your application.
  applyEvent: async (event) => {
    await invalidateResources(event.changes)
  },
  resync: async () => {
    await reloadAuthoritativeState()
  },
})

await realtime.start()

This example runs on the server. For browsers, make ticketProvider call your same-origin server ticket endpoint. That endpoint must request a ticket with the browser's exact registered Origin. Generate the AsyncAPI specification for frame schemas and connection rules.