Quick Start
Deploy your first game server in 5 minutes
Quick Start Guide
Get your first CS2 match running in just a few minutes.
Prerequisites
- Node.js 18+ installed
- A SweatHost account (sign up here)
- An API key from your dashboard
Step 1: Install the SDK
Install the SweatHost SDK using your preferred package manager:
npm install @sweathost/sdkpnpm add @sweathost/sdkyarn add @sweathost/sdkStep 2: Get Your API Key
- Log in to your SweatHost Dashboard
- Navigate to API Keys in the sidebar
- Click Create API Key
- Name your key (e.g., "Development")
- Select scopes:
servers:read,servers:write - Copy the API key (save it securely!)
Important: Your API key will only be shown once. Store it securely!
Step 3: Start Your First Match
Create a new file match.ts and start a match with a single call:
import { SweatHostClient } from '@sweathost/sdk';
const client = new SweatHostClient({
apiKey: process.env.SWEATHOST_API_KEY!,
});
async function main() {
// Start an ephemeral match — creates server, allocates pod, starts game
const match = await client.matches.create({
region: 'us-west-1',
gameType: 'cs2',
gameSettings: {
matchType: 'competitive',
map: 'de_dust2',
seriesFormat: 'bo1',
},
});
console.log('Match started!');
console.log(` Server ID: ${match.serverId}`);
console.log(` Status: ${match.status}`);
console.log(` IP: ${match.ip}:${match.port}`);
}
main().catch(console.error);Run Your Code
# Set your API key
export SWEATHOST_API_KEY="your-api-key-here"
# Run the script
npx tsx match.tsComplete Example with Teams and Callbacks
Here's a full competitive match with team rosters and webhook callbacks:
import { SweatHostClient } from '@sweathost/sdk';
const client = new SweatHostClient({
apiKey: process.env.SWEATHOST_API_KEY!,
});
async function main() {
const match = await client.matches.create({
region: 'us-west-1',
gameType: 'cs2',
callbackUrl: 'https://example.com/webhooks/match',
callbackAuthToken: 'Bearer my-secret-token',
externalMatchId: 'my-tournament-match-1',
gameSettings: {
matchType: 'competitive',
map: 'de_dust2',
maps: ['de_dust2', 'de_mirage', 'de_inferno'],
seriesFormat: 'bo3',
teams: {
team1: { name: 'Alpha', players: ['76561198000000001', '76561198000000002'] },
team2: { name: 'Beta', players: ['76561198000000003', '76561198000000004'] },
},
},
});
console.log(`Match created: ${match.serverId}`);
console.log(`Connect: ${match.ip}:${match.port}`);
// When the match ends, your callbackUrl receives a POST with results
}
main().catch(console.error);Check Match Status
const server = await client.servers.get('server-id');
console.log(`Status: ${server.status}`);Cancel a Match
await client.servers.cancel('server-id');
console.log('Match canceled and server destroyed');Next Steps
Now that you have a match running, explore more features:
Game Servers API
Full API reference for matches and servers
Match Analytics
Access match data and statistics
Deathmatch
Run deathmatch competitions
Regions
Choose optimal server locations
Common Issues
"Invalid API key"
Make sure you're using the correct API key and it has the required scopes (servers:read, servers:write).
"Region not available"
Check available regions with:
const regions = await client.regions.list();
console.log(regions.map(r => r.code));Get Help
Need assistance?