SweatHost
SDK Reference

SDK Overview

Official JavaScript/TypeScript SDK for the SweatHost API

SweatHost SDK

The official JavaScript/TypeScript SDK for interacting with the SweatHost game server platform.

Features

  • 🎮 Game Server Management - Create, configure, and control CS2 game servers
  • 📊 Match Analytics - Access detailed match statistics and player performance data
  • 🌍 Region Selection - Query available regions and find optimal server locations
  • 🔒 Type-Safe - Full TypeScript support with comprehensive type definitions
  • Promise-Based - Modern async/await API
  • 🛡️ Error Handling - Detailed error types and messages

Quick Example

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

const client = new SweatHostClient({
  apiKey: 'your-api-key',
});

// List all game servers
const servers = await client.gameServers.list();

// Get match details
const match = await client.matches.get('match-id');

// Find optimal region
const region = await client.regions.findOptimal({
  playerLocations: ['US', 'EU'],
});

Installation

Get started by installing the SDK:

npm install @sweathost/sdk

View installation guide →

Core Modules

Game Servers

Manage your CS2 game servers with full lifecycle control.

// Create a server
const server = await client.gameServers.create({
  name: 'My CS2 Server',
  region: 'us-west-1',
  game: 'cs2',
});

// Control the server
await client.gameServers.start(server.id);
await client.gameServers.stop(server.id);

View Game Servers API →

Matches

Access comprehensive CS2 match data and player statistics.

// List recent matches
const matches = await client.matches.list({
  status: 'finished',
  pageSize: 10,
});

// Get detailed match data
const match = await client.matches.get('match-id');

// Get comprehensive statistics
const stats = await client.matches.getStats('match-id');

View Matches API →

Regions

Query available regions and optimize server placement.

// List all regions
const regions = await client.regions.list();

// Find best region for players
const optimal = await client.regions.findOptimal({
  playerLocations: ['US-CA', 'US-NY', 'EU-GB'],
});

View Regions API →

TypeScript Support

The SDK is written in TypeScript and provides full type definitions:

import type {
  GameServer,
  Match,
  Region,
  PlayerStats,
} from '@sweathost/sdk';

// All responses are fully typed
const server: GameServer = await client.gameServers.get('server-id');
const match: Match = await client.matches.get('match-id');

Error Handling

The SDK provides detailed error information:

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

try {
  await client.gameServers.create({ /* ... */ });
} catch (error) {
  if (error instanceof ApiClientError) {
    console.error(`Error ${error.statusCode}: ${error.message}`);
    
    // Access validation errors
    if (error.errors) {
      console.error('Validation errors:', error.errors);
    }
  }
}

View Error Handling →

Support

Need help? We're here for you:

Next Steps

On this page