WebSocket connection (Socket.IO)

WebSocket Real-Time Events

This is a Socket.IO WebSocket endpoint, not a REST endpoint. This documentation describes the WebSocket protocol.

Connection

Connect using a Socket.IO client to the /events path:

import { io } from "socket.io-client";

const socket = io("https://{domain}/nbc", {
  path: "/players/@me/events",
  transports: ["websocket", "polling"],
  auth: {
    bearer: "<player-jwt-token>"
  }
});

Authentication

Provide a valid player JWT token in the auth.bearer field during the handshake. Connections without a valid token are rejected with an Unauthorized error.

Events (Server → Client)

EventPayloadDescription
game.event.updatestring (dataType)Emitted when a game event occurs for the connected player. The payload is the event's dataType string (see examples below).

dataType values

The dataType payload is a string identifying what happened. Common examples:

dataTypeTrigger
LEVEL_UPPlayer reached a new level
REWARD_DISTRIBUTEDA reward was given to the player
QUEST_COMPLETEDPlayer completed a quest
QUEST_STARTEDA quest was started for the player
CHALLENGE_COMPLETEDPlayer completed a challenge
CHALLENGE_PROGRESS_UPDATEDProgress on a challenge changed
PERK_REWARDEDA perk was awarded to the player
PERK_ACTIVATEDPlayer activated a perk
DAILY_CLAIMEDPlayer claimed a daily bonus
ACHIEVEMENT_REWARD_CLAIMEDPlayer claimed an achievement reward
LEADERBOARD_ROTATEDA leaderboard rotation occurred
POLL_VOTE_SUBMITTEDPlayer submitted a poll vote
ASSIGNMENT_GIVENAn assignment was given to the player
ASSIGNMENT_COMPLETEDPlayer completed an assignment
USER_CREATEDA new user was created

Use dataType to decide which parts of the UI to refresh (e.g., re-fetch quests on QUEST_COMPLETED, re-fetch balance on REWARD_DISTRIBUTED).

Example: Listening to events

socket.on("game.event.update", (dataType) => {
  switch (dataType) {
    case "REWARD_DISTRIBUTED":
      refreshBalance();
      break;
    case "QUEST_COMPLETED":
      refreshQuests();
      break;
    case "LEVEL_UP":
      showLevelUpAnimation();
      break;
    default:
      console.log("Event received:", dataType);
  }
});

socket.on("connect_error", (err) => {
  console.error("Connection failed:", err.message);
});
Language
Credentials
Bearer
JWT
URL
Response
Click Try It! to start a request and see the response here!