API Reference

Complete reference for Browser and Server SDKs.

Browser

<script src="https://www.indie.fun/js/indie.js"></script>

Setup

new Indie({ appId })Create client — auto-mounts login widget and tracks sessions
new Indie({ appId, consent })consent: 'auto' (default) shows an EU/UK guest-analytics banner; 'manual' lets you drive consent yourself; 'off' disables gating.

Guest analytics consent

indie.optIn()Allow anonymous analytics for this visitor and start tracking.
indie.optOut()Decline/withdraw consent. Stops guest tracking and drops the device id.
indie.getConsent()Returns 'granted' | 'denied' | 'unknown'. Do-Not-Track / GPC report 'denied'.

Logged-in players are always counted. The widget handles login automatically and notifies your game server via WebSocket when a player joins.

Server

npm install indie-sdk

const { Indie } = require('indie-sdk/server')

Setup

new Indie({ appId, appSecret })Connect to Indie and start receiving player events

Events

indie.on('playerJoin', (player) => {})Called when a player logs in. player has id, name, data, highScore, permissions.

Player Data

indie.getPlayerData(playerId)Load all saved data for a player. Returns Promise<object>.
indie.savePlayerData(playerId, data)Replace all data for a player. Returns Promise<void>.
indie.updatePlayerData(playerId, data)Merge fields into existing data (partial update). Returns Promise<void>.

Types

Player

{
  id: string
  name: string
  data: Record<string, unknown>
  highScore: number
  permissions: Record<string, boolean>
}