bz2api.js

A lightweight JavaScript library for querying Battlezone 2: Combat Commander multiplayer session data. Works in browsers and Node.js with automatic CORS handling.

const result = await BZ2API.fetchSessions();

// Result includes parsed sessions
result.sessions.forEach(session => {
  console.log(session.name);
  console.log(session.players);
  console.log(session.mapFile);
});

Features

Everything you need to integrate BZ2 multiplayer data into your apps

CORS Handling

Automatic proxy fallback for browser-based apps. Works out of the box without server configuration.

Full Data Parsing

Complete parsing of session data including players, stats, game modes, NAT types, and more.

Map Enrichment

Optional map data enrichment with images, descriptions, and team names from external APIs.

VSR Support

Built-in support for VSR (Vet Strategy Recycler) mod with map metadata like pools and loose scrap.

Steam Integration

Player profile URLs, Steam Workshop mod links, and direct game join URLs.

Universal

Works in browsers (vanilla JS, React, Vue) and server-side (Node.js) environments.

Quick Start

Get up and running in seconds. Just include the script and start fetching session data.

Installation Options:
Download bz2api.js
GitHub View Source
// Include the script
<script src="bz2api.js"></script>

// Fetch all active sessions
const result = await BZ2API.fetchSessions();
console.log(result.sessions);

// With map enrichment
const enriched = await BZ2API.fetchSessions({
  enrichMaps: true,
  enrichVsrMaps: true
});

// Access session data
enriched.sessions.forEach(s => {
  console.log(`${s.name}: ${s.playerCount}/${s.maxPlayers}`);
});

Rich Session Data

Every session is parsed into a comprehensive, ready-to-use object

{
  "name": "VSR Dedicated DM Server",
  "state": "InGame",
  "gameType": "DM",
  "gameModeName": "Deathmatch",
  "mapFile": "rckcnynvsr",
  "mapName": "VSR DM: Rocky Canyon",        // Enriched
  "mapImageUrl": "https://...",             // Enriched
  "playerCount": 3,
  "maxPlayers": 14,
  "players": [
    {
      "name": "PlayerOne",
      "steamId": "76561198...",
      "profileUrl": "https://steamcommunity.com/...",
      "kills": 15,
      "deaths": 8,
      "score": 42
    }
  ],
  "gameBalance": "VSR",
  "steamJoinUrl": "steam://rungame/...",
  // ...and 30+ more fields
}