C++ SDK — Game Data

Game Data

getGameData
template<typename T = nlohmann::json>
static GameDataResponse<T> getGameData(Client& client)

Retrieves global game data with nlohmann::json compatible nested objects.

updateGameData
template<typename T>
static SuccessResponse updateGameData(Client& client, const T& data)

Updates global game data (requires private API token). Uses template type for type safety.

getPlayerData
template<typename T = nlohmann::json>
static PlayerDataResponse<T> getPlayerData(
    Client& client,
    const std::string& playerToken
)

Retrieves a specific player's data using their authentication token with typed support.

updatePlayerData
template<typename T>
static SuccessResponse updatePlayerData(
    Client& client,
    const std::string& playerToken,
    const T& data
)

Updates a specific player's data like level, score, and inventory with template type support.

Two scopes of JSON storage

Game data is JSON your game owns, kept at two scopes. The game-scope blob holds live configuration — name and room rules, version policy, client config — that every SDK reads at startup, so rule tweaks reach players without shipping a client update. The player-scope record per user carries progression: stats, loadouts, unlocks and match state that must outlive sessions.

Reads need only the public API token since the game blob is world-readable. Writes are privileged: game scope requires the private token, and a player record requires that player's token or admin credentials. Player fields are also what the leaderboard sorts — keep ranked fields numeric and consistently named across builds.

  • Treat the game blob as remote config: small, versioned, read at startup — not a per-frame channel.
  • Name rules and room rules apply server-side at register, rename and room creation; SDKs validate locally for instant feedback but the server verdict is final.
  • Ranked fields live in player data — write them under the same names on every platform or the board splits.
  • Calls are synchronous functions that take the client by reference — keep them off the frame-critical path in games that cannot stall, and use the typed template overloads to deserialize player data into your own structs.