The DatHost API

Introduction

You can use the DatHost API to automate creation/deletion and control of servers if you for example want to integrate our game servers into your service. The API is a RESTful HTTP API which means that all interactions are made using regular HTTP requests, if you are logged in you can even try out the functionality in your web browser below.

To authenticate with our API use HTTP basic authentication with login email and password. You should send the basic auth header with every request. By default all actions are done against the account you authenticate to, if you are invited to another account you can add the HTTP header Account-Email: <email> with the login email of the account which you like to do the action on.

If you have any questions or suggestions get in touch with support@dathost.net


CS:GO Match Configuration

If you plan to use the API to integrate with some CS:GO match service of yours, we would recommend having a look at the match endpoint in our API. That includes everything needed to get going with an automated match solution.

Read more in our CS:GO Match Documentation PDF here.


How to get started

Python Example

This is a fully working Python program using the requests module, which creates a server, starts it and retrieves ip + port:

import requests

server = requests.post(
    "https://dathost.net/api/0.1/game-servers",
    data={
        "name": "test",
        "game": "csgo",
        "csgo_settings.rcon": "test",
        "csgo_settings.steam_game_server_login_token": "B9184AB935BA3419258338383BCA3CA",
    },
    auth=("john@doe.com", "secretPassword"),
).json()

requests.post(
    "https://dathost.net/api/0.1/game-servers/%s/start" % server["id"],
    auth=("john@doe.com", "secretPassword"),
)

server = requests.get(
    "https://dathost.net/api/0.1/game-servers/%s" % server["id"],
    auth=("john@doe.com", "secretPassword"),
).json()

print("%s:%s" % (server["ip"], server["ports"]["game"]))

NodeJS (JavaScript) example

This is a fully working NodeJS (JavaScript) program which creates a server, starts it and retrieves ip + port:

const FormData = require('form-data')
const fetch = require('node-fetch')

async function main() {
  const username = 'john@doe.com'
  const password = 'secretPassword'
  const headers = {
    authorization: `Basic ${Buffer.from(`${username}:${password}`).toString('base64')}`,
  }

  let body = new FormData()
  body.append('name', 'test')
  body.append('game', 'csgo')
  body.append('csgo_settings.rcon', 'test')
  body.append('csgo_settings.steam_game_server_login_token', 'B9184AB935BA3419258338383BCA3CA')

  let response = await fetch('https://dathost.net/api/0.1/game-servers', {
    method: 'POST',
    body,
    headers,
  })

  let server = await response.json()

  await fetch(`https://dathost.net/api/0.1/game-servers/${server.id}/start`, {
    method: 'POST',
    headers,
  })

  response = await fetch(`https://dathost.net/api/0.1/game-servers/${server.id}`, {
    headers,
  })

  server = await response.json()

  console.log(`${server.ip}:${server.ports.game}`)
}

main()

API Specification

Note: Click on a resource to get detailed info