SweatHost
SDK Reference

Deathmatch

Start tracked deathmatch competitions and retrieve per-session player stats for CS2 Deathmatch servers (FFA and Team DM)

Deathmatch

The deathmatch resource lets you list sessions, retrieve full player stats, and fetch sorted leaderboards for CS2 Deathmatch matches.

Starting a deathmatch match

Use client.matches.create() with matchType: "deathmatch" to start a deathmatch match. This single call creates the server, allocates a pod, configures the game, and optionally sets up whitelist, auto-start, callbacks, and auto-shutdown.

Starting a deathmatch match

const match = await client.matches.create({
  region: 'us-west-1',
  gameType: 'cs2',
  callbackUrl: 'https://example.com/webhooks/match',
  callbackAuthToken: 'Bearer my-secret-token',
  externalMatchId: 'dm-lobby-99',
  gameSettings: {
    matchType: 'deathmatch',
    map: 'de_dust2',
    dmSubMode: 'ffa',
    dmRoundMinutes: 10,
    players: ['76561198000000001', '76561198000000002', '76561198000000003'],
  },
});

console.log(`Server: ${match.serverId}`);
console.log(`Connect: ${match.ip}:${match.port}`);
FeatureBehavior
WhitelistOnly listed players can connect. Unauthorized players are kicked.
Auto-startMatch stays in warmup until every listed player has joined. Once the last player connects, the game starts right away — warmup ends, round restarts, stats begin recording.
CallbackAPI POSTs match_over or match_canceled to your callbackUrl with player stats and your externalMatchId.
Auto-shutdownServer is destroyed immediately after match ends.

See also

Full createMatch() reference with callback payload examples: Game Servers API → createMatch()


listSessions

List deathmatch sessions for your organization with optional filters.

const response = await client.deathmatch.listSessions({
  status: 'finished',
  serverId: 'your-server-id',
  page: 1,
  pageSize: 20,
});

console.log(response.total); // total number of sessions
console.log(response.items); // CS2DeathmatchSessionSummary[]

Parameters

NameTypeDescription
serverIdstringFilter by server ID
status'live' | 'finished' | 'cancelled'Filter by session status
dateFromstringISO 8601 date — sessions started after this date
dateTostringISO 8601 date — sessions started before this date
pagenumberPage number (default: 1)
pageSizenumberResults per page (default: 20, max: 100)

Response: ListDeathmatchSessionsResponse

{
  page: number;
  pageSize: number;
  total: number;
  items: CS2DeathmatchSessionSummary[];
}

Each CS2DeathmatchSessionSummary:

{
  id: string;
  sessionId: string;
  serverId: string;
  subMode: 'ffa' | 'team';
  mapName: string;
  status: string;
  startedAt: string;
  finishedAt?: string | null;
  playerCount: number;
}

getSession

Get a single deathmatch session with the full player stats array.

const session = await client.deathmatch.getSession('session-id-here');

console.log(session.mapName);   // e.g. "de_dust2"
console.log(session.subMode);   // "ffa" or "team"
console.log(session.players);   // CS2DeathmatchPlayerStats[]

Response: CS2DeathmatchSession

{
  id: string;
  sessionId: string;
  serverId: string;
  subMode: 'ffa' | 'team';
  mapName: string;
  status: 'live' | 'finished' | 'cancelled';
  startedAt: string;
  finishedAt?: string | null;
  duration?: number | null; // seconds
  players: CS2DeathmatchPlayerStats[];
}

Each CS2DeathmatchPlayerStats:

{
  id: string;
  sessionId: string;
  steamId: string;
  name: string;
  team: number;            // 2=T, 3=CT, 0=FFA
  kills: number;
  deaths: number;
  assists: number;
  headshots: number;
  damageDealt: number;
  bulletsFired: number;
  bulletsHit: number;
  accuracyPercent?: number | null;
  hsPercent?: number | null;
  kdRatio?: number | null;
  kpm?: number | null;     // kills per minute
  utilityDamage?: number | null;
  flashAssists?: number | null;
  firstKills?: number | null;
  firstDeaths?: number | null;
  entryKills?: number | null;
  tradeKills?: number | null;
  adr?: number | null;
  roundsPlayed?: number | null;
  kastPercent?: number | null;
  impactRating?: number | null;
}

getLeaderboard

Get a sorted leaderboard for a deathmatch session.

const leaderboard = await client.deathmatch.getLeaderboard('session-id-here', {
  sortBy: 'kills',
});

leaderboard.players.forEach((player, rank) => {
  console.log(`#${rank + 1} ${player.name}: ${player.kills} kills`);
});

Parameters

NameTypeDescription
sortBy'kills' | 'kd' | 'headshots' | 'damage' | 'kpm'Sort field (default: kills)

Response: CS2DeathmatchLeaderboard

{
  sessionId: string;
  sortBy: string;
  players: CS2DeathmatchPlayerStats[]; // sorted descending by sortBy field
}

Sub-modes

Sub-modedeathmatch_modeDescription
ffa0Free-For-All — every player fights independently
team1Team Deathmatch — Terrorists vs Counter-Terrorists

The sub-mode is set via dmSubMode in the gameSettings when creating a match.

Round duration

Set dmRoundMinutes in gameSettings to control how long each deathmatch round lasts. This maps to the CS2 mp_timelimit CVar. If omitted, the server uses the CS2 default.


Full example: start and poll a competition

import { SweatHostClient } from '@sweathost/sdk';

const client = new SweatHostClient({ apiKey: process.env.SWEATHOST_API_KEY! });

// 1. Start the match
const match = await client.matches.create({
  region: 'us-west-1',
  gameType: 'cs2',
  gameSettings: {
    matchType: 'deathmatch',
    map: 'de_dust2',
    dmSubMode: 'ffa',
    dmRoundMinutes: 10,
    players: ['76561198000000001', '76561198000000002', '76561198000000003'],
  },
});

console.log('Match started:', match.serverId);

// 2. Poll the leaderboard every 10 seconds while live
async function pollLeaderboard(sessionId: string) {
  const board = await client.deathmatch.getLeaderboard(sessionId, {
    sortBy: 'kills',
  });

  board.players.forEach((p, i) => {
    console.log(`#${i + 1} ${p.name} — ${p.kills}K / ${p.deaths}D (${p.kdRatio?.toFixed(2)} KD)`);
  });

  const current = await client.deathmatch.getSession(sessionId);
  if (current.status === 'live') {
    setTimeout(() => pollLeaderboard(sessionId), 10_000);
  } else {
    console.log('Session finished. Final stats:', current.players);
  }
}

pollLeaderboard(match.gameId);

On this page