motortown-docs

Motor Town Dedicated Server Web API Documentation

Unofficial documentation for the server Web API.

Adapted by @catb0t (psybrcatTRL) from the officially distributed Dedi ReadMe.txt.

Best interpretation of the official ReadMe, but it may contain mistakes.

Especially, descriptions of exact field meanings/semantics and endpoint behaviour are inferred and written with my best knowledge of the game and testing the API, but may differ from the source code.

Contents

Hosting Web API Server

You can enable Web API Server to get server status and player/delivery/housing information, send chat/announce messages, kick and ban players, and change player roles.

DedicatedServerConfig.json Parameters

About Web API Return Values

API returns JSON string with following format

{
  "data": {},
  "message": "",
  "succeeded": true,
  "code": 0
}

About Web API password

You should set "HostWebAPIServerPassword" to a string in DedicatedServerConfig.json. Currently, stored in plaintext, so be careful.

You need to pass the password as a parameter in each API call.

Note that the password is sent unencrypted because of current lack of Web API HTTPS/TLS. It's not recommended to send it over the public internet unless you can use another layer of encryption.

API call example

GET  /player/count/
     ?password=your_password
POST /player/kick/
     ?password=your_password
     &unique_id=player_unique_id
     &reason=reason

Web API Endpoint List

GET Endpoints

Get parameters are provided in the request URL query string, not as JSON.

GET /version

Get the current game version string of the server.
Version parts:

Returns:

Example:

  "data": { "version": "0.7.13+CT4(B804)" }

GET /player/count

Returns:

num_players: int

Example:

  "data": { "num_players": 2 }

GET /player/list

Returns:

Example:

  "data": {
    "0": {
      "name": "jake",
      "unique_id": "12345",
      "location": "X=2590.089 Y=1682.984 Z=98.927",
      "vehicle":
      {
        "name": "Scooty",
        "unique_id": 175114
      }

    },
    "1": {
      "name": "dooli",
      "unique_id": "12346",
      "location": "X=-108.632 Y=463.258 Z=188.150"
    }
  }

GET /player/banlist

Returns:

Example:

    "data": {
      "0": {
        "name": "jake",
        "unique_id": "12345"
        }
      }

GET /player/role/list

Returns an object of 0-indexed player objects matching the input role type.

Parameters:

Returns:

Example:

  "data": {
    "admin":
    {
      "0":
      {
        "unique_id": "12345",
        "nickname": "dooli"
      },
      "1":
      {
        "unique_id": "67890",
        "nickname": "betty"
      }
    }
  }

GET /delivery/sites

Returns an object of 0-indexed keys of job sites in the world. A job site may have multiple in-game markers which refer to the same inventory and delivery jobs (contracts).

Returns:

Example:

  "data": {
    "17": {
      "guid": "A65CAFE44ABD6FBBB130BC953C85E1BD",
      "name": "Construction Site",
      "location": "X=-3350.465 Y=2.171 Z=100.000",
      "Deliveries": {
        "0": {
          "id": 68,
          "cargo_type": "Sand",
          "num_cargos": "1/1",
          "sender_point": "A65CAFE44ABD6FBBB130BC953C85E1BD",
          "receiver_point": "2F3A8E4C4CB0A3A1273B8A8036FCDBCA",
          "register_time": 122.30276489257812,
          "expire_time": 482.48467864096165,
          "base_payment": 5,
          "timer_seconds": -1
        }
      },
      "InputInventory": {
        "0": {
          "amount": 0,
          "cargo": {
            "name": "Carrots",
            "type": "Box",
            "space_types": "Flatbed, Box",
            "volume_size": 1,
            "weight_range": "X=0.000 Y=0.000",
            "allow_stacking": "false",
            "use_damage": "false",
            "fragile": 0,
            "spawn_probability": 10,
            "num_cargo_range": "X=1 Y=2",
            "base_payment": 0,
            "payment_per1km": 220,
            "delivery_distance_range": "X=0 Y=0"
          }
        }
      },
      "OutputInventory": {
        "0": {
          "amount": 1,
          "cargo": {
            "name": "Sand",
            "type": "Sand",
            "space_types": "Dump",
            "volume_size": 1,
            "weight_range": "X=1600.000 Y=1600.000",
            "allow_stacking": "false",
            "use_damage": "false",
            "fragile": 0,
            "spawn_probability": 10,
            "num_cargo_range": "X=5 Y=20",
            "base_payment": 0,
            "payment_per1km": 380,
            "delivery_distance_range": "X=0 Y=0"
          }
        }
      }
    }
  }

GET /housing/list

Get all the player-ownable houses on the map, indexed by name.

Returns:

  "data":{
    "HousingTest_House0": {
      "owner_unique_id": "12345",
      "expire_time": "2025.04.11-03.04.57 (+6 days 23 hours)"
    }
  }

POST Endpoints

Post parameters are provided in the request URL query string, not as JSON.

The top-level data key will be empty. Check the message string key for the message and the succeeded boolean key for whether the server thinks it did what you asked.

In general, for a successful request, the return object will have:

code will be 0.
succeeded will be true.


POST /chat

Send an announcement or a message to the server. No formatting is applied to chat messages, i.e. does not automatically start with [SERVER] or similar.

Parameters:

Returns:

Success: - message will be message sent.

POST /player/kick

Kick a player by Steam ID.

Parameters:

Returns:

Success: - message will be Player kicked

Example:

  {
    "data": { },
    "message": "Player kicked",
    "succeeded": true,
    "code": 0
  }

POST /player/ban

Ban a player by their Steam ID. If the player is on the server, they will be kicked and shown the reason message in a dialog box. They’ll be unable to rejoin the server until hours has passed, or permanently if not provided.

If the player isn’t on the server, the player will be added as a BannedPlayers entry to the GameUserSettings.ini, with the other attributes recorded. As above, they won’t be able to join until hours pass or indefinitely.

Parameters:

Returns:

Success: - message will be Player banned

Example:

  {
    "data": { },
    "message": "Player banned",
    "succeeded": true,
    "code": 0
  }

POST /player/unban

Parameters:

Returns:

Success: - message will be Player unbanned

Example:

  {
    "data": { },
    "message": "Player unbanned",
    "succeeded": true,
    "code": 0
  }

POST /player/role/add

Add the player by Steam ID to the named role. Results in an immediate role change for an online player, and updates GameUserSettings.ini with the entry.

Because the GameUserSettings file is a flat data structure, each role applied to a player is its own line instead of a nested data structure either of Player objects with roles or Role objects with Players.

If a player has both "admin" and "police", two separate line entries will denote the player and each role.

Parameters:

Returns:

Success: - ?

Example:

?

POST /player/role/remove

Remove the player by Steam ID to the named role. Results in an immediate role change for an online player, and updates GameUserSettings.ini by removing the entry.

Because the GameUserSettings file is a flat data structure, each role applied to a player is its own line instead of a nested data structure either of Player objects with roles or Role objects with Players.

If a player has both "admin" and "police", two separate line entries will denote the player and each role.

Parameters:

Returns:

Success: - ?

Example:

?