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
Header | Value |
---|---|
Content-Type | application/json |
Body
The request body must be a JSON object containing the following fields:
Field | Type | Required | Description |
---|---|---|---|
reference_id | string | Yes | A unique identifier for the lobby. |
lobby_name | string | Yes | The name of the lobby. |
lobby_password | string | Yes | The password for the lobby. |
game_mode | string | Yes | The game mode for the lobby (e.g., 1 for All Pick). |
region | string | Yes | The server region for the lobby (e.g., 10 for US East). |
visibility | string | Yes | The visibility of the lobby (0 for public, 1 for private). |
players | array | Yes | A 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:
- Create new lobbies with specific configurations.
- Assign players to teams within the lobby.
- 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.