Skip to main content

API Endpoint: /new-lobby

Description

The /new-lobby endpoint is used to create a new Dota 2 lobby. It accepts a JSON payload with the lobby configuration and player details, then initializes the lobby using the provided parameters. This endpoint is essential for managing custom lobbies in the Meepow Management API.

HTTP Method

  • POST

Request

Headers

HeaderValue
Content-Typeapplication/json

Body

The request body must be a JSON object containing the following fields:

FieldTypeRequiredDescription
reference_idstringYesA unique identifier for the lobby.
lobby_namestringYesThe name of the lobby.
lobby_passwordstringYesThe password for the lobby.
game_modestringYesThe game mode for the lobby (e.g., 1 for All Pick).
regionstringYesThe server region for the lobby (e.g., 10 for US East).
visibilitystringYesThe visibility of the lobby (0 for public, 1 for private).
playersarrayYesA list of players with their Steam IDs and assigned teams (radiant/dire).

Example Request Body

{
"reference_id": "unique-id-123",
"lobby_name": "My Custom Lobby",
"lobby_password": "password123",
"game_mode": "1",
"region": "10",
"visibility": "0",
"players": [
{ "steam_id": "123456789", "team": "radiant" },
{ "steam_id": "987654321", "team": "dire" }
]
}

Response

Success Response

  • Status Code: 201 Created
    Indicates that the lobby was successfully created.

  • Body:
    A JSON object with details about the created lobby.

{
"message": "Lobby created successfully",
"lobby_id": "unique-id-123"
}

Error Responses

  • Status Code: 400 Bad Request
    Indicates that the request body is invalid or missing required fields.
{
"error": "Invalid request payload"
}

Example Request

cURL Command

curl -X POST http://localhost:3000/new-lobby \
-H "Content-Type: application/json" \
-d '{
"reference_id": "unique-id-123",
"lobby_name": "My Custom Lobby",
"lobby_password": "password123",
"game_mode": "1",
"region": "10",
"visibility": "0",
"players": [
{ "steam_id": "123456789", "team": "radiant" },
{ "steam_id": "987654321", "team": "dire" }
]
}'

Response

{
"message": "Lobby created successfully",
"lobby_id": "unique-id-123"
}

Purpose

This endpoint is used to:

  1. Create new lobbies with specific configurations.
  2. Assign players to teams within the lobby.
  3. Automate the setup of custom Dota 2 matches.

Implementation

The /new-lobby endpoint is implemented in the runServer function:

r.HandleFunc("/new-lobby", func(w http.ResponseWriter, r *http.Request) {
handlers.NewLobby(w, r, configs, lobbyManager)
}).Methods(http.MethodPost)

The logic for processing the request and creating the lobby is handled by the handlers.NewLobby function.