Skip to content

SECTION 9 — ANALYTICS: LIVE

51. POST /analytics/live/session/start

Called when a user starts watching a live stream.

Request

http
POST /analytics/live/session/start
Content-Type: application/json
Authorization: Bearer <token>

Request Body

json
{
  "session_id": "sess_live_xyz001",
  "user_id": "user_123",
  "device_id": "device_abc123",
  "platform": "web",
  "app_version": "2.4.1",
  "stream": {
    "stream_id": "stream_abc123",
    "channel_id": "ch_101",
    "creator_id": "creator_001",
    "creator_name": "Chris Spencer"
  },
  "epg": {
    "current_program_id": "prog_002",
    "current_program_title": "Behind the Laughs",
    "program_position_seconds": 900
  },
  "playback": {
    "quality": "auto",
    "latency_mode": "low",
    "dvr_enabled": false
  },
  "device": {
    "type": "web",
    "os": "macOS",
    "os_version": "14.0",
    "browser": "Chrome",
    "browser_version": "119.0",
    "screen_resolution": "1920x1080",
    "connection_type": "wifi"
  },
  "geo": { "country": "US", "state": "Georgia", "city": "Atlanta", "timezone": "America/New_York" },
  "referrer": { "source": "creator_zone", "page": "/creators/chris-spencer", "section": "channel_live" },
  "timestamp": "2024-11-01T18:15:00Z"
}

Request Body Parameters (key fields)

FieldTypeRequiredDescription
session_idstringYesUnique session ID
user_idstringNoUser ID (null for guests)
device_idstringYesDevice fingerprint
platformstringYesweb, ios, android, roku, firetv, appletv
stream.stream_idstringYesLive stream ID
stream.channel_idstringYesChannel ID
stream.creator_idstringYesCreator ID
epg.current_program_idstringYesCurrent program ID
playback.qualitystringYesInitial stream quality
playback.latency_modestringYeslow, normal
playback.dvr_enabledbooleanYesWhether DVR is on
device.connection_typestringYeswifi, cellular, ethernet
geo.countrystringYesCountry code
timestampstringYesISO 8601 UTC

Response 200 OK

json
{
  "status": "success",
  "data": {
    "session_id": "sess_live_xyz001",
    "accepted": true,
    "heartbeat_interval_seconds": 30,
    "server_timestamp": "2024-11-01T18:15:00Z"
  }
}

52. POST /analytics/live/session/heartbeat

Called every 30 seconds during live viewing.

Request Body

Include session_id, user_id, device_id, stream_id, channel_id, creator_id, epg (current_program_id, current_program_title, program_elapsed_seconds, program_progress_percent), playback (is_playing, is_paused, is_buffering, quality, volume_level, dvr_offset_seconds), performance (buffer_health_seconds, rebuffer_count, bitrate_kbps, latency_ms), engagement, and timestamp.

Response 200 OK

json
{
  "status": "success",
  "data": {
    "session_id": "sess_live_xyz001",
    "accepted": true,
    "next_heartbeat_seconds": 30,
    "server_timestamp": "2024-11-01T18:15:30Z"
  }
}

53. POST /analytics/live/session/end

Called when user exits the live stream.

Request Body (key fields)

FieldTypeRequiredDescription
session_idstringYesSession ID
watch_summary.total_watch_secondsintYesTotal watch time
watch_summary.end_reasonstringYesuser_exit, error, timeout, inactivity
watch_summary.programs_watchedarrayYesPrograms watched during session
performance.total_rebuffer_countintYesTotal rebuffer events
performance.quality_switchesintYesQuality changes
engagement.total_chat_messages_sentintYesChat messages sent
engagement.total_reactions_sentintYesReactions sent
timestampstringYesISO 8601 UTC

Response 200 OK

json
{
  "status": "success",
  "data": {
    "session_id": "sess_live_xyz001",
    "accepted": true,
    "watch_summary": {
      "total_watch_seconds": 2340,
      "total_watch_formatted": "39:00",
      "end_reason": "user_exit"
    },
    "server_timestamp": "2024-11-01T18:54:00Z"
  }
}

54. POST /analytics/live/events

Post discrete live stream player events.

Request Body

Send session_id, user_id, device_id, stream_id, creator_id, and an events array. Each event has event_id, event_type, timestamp, and optional metadata.

Supported Live Event Types

Event TypeDescription
stream_startLive playback started
stream_buffer_start / stream_buffer_endBuffering began/ended
stream_reconnect / stream_reconnect_successReconnection
stream_errorStream error occurred
program_changeEPG program changed
quality_changeStream quality changed
fullscreen_enter / fullscreen_exitFullscreen
mute / unmuteAudio muted/unmuted
dvr_seekUser seeked via DVR
dvr_resume_liveReturned to live from DVR
reactionUser sent reaction
shareUser shared stream
followUser followed during stream
subscribeUser subscribed during stream
tipUser tipped during stream

Response 200 OK

json
{
  "status": "success",
  "data": {
    "session_id": "sess_live_xyz001",
    "accepted_count": 5,
    "rejected_count": 0,
    "rejected_events": [],
    "server_timestamp": "2024-11-01T19:00:00Z"
  }
}