HiveMP Lobbies Quickstart

How did we do?

This quickstart shows you how to create a new game lobby, join it and then list the sessions in the lobby.

You'll need to have a session API key to use in this quickstart. You can create a session API key with the HiveMP Sessions' HiveMP Sessions Quickstart.

Create a game lobby

curl -s \
  -H "X-API-Key: $apiKey" \
  -H "Accept: application/json" \
  -H "Content-Length: 0" \
  -X PUT \
  "https://lobby-api.hivemp.com/v1/lobby"\
"?name=My+Game+Lobby"\
"&maxSessions=4"

After executing this method, you'll get a new game lobby that looks like this:

{
  "currentSessions": 0,
  "id": "lb-5752141660553216",
  "maxSessions": 4,
  "name": "My Game Lobby",
  "ownerSessionId": "us-5722461490380800"
}

If you were to list the sessions in the game lobby now, your current session would not be listed. This is because creating a game lobby does not automatically join you to it.

Join a game lobby

To join the game lobby, you need to use the lobby ID and your current session ID. The lobby ID and your current session ID will both appear in the response when you created a game lobby (your current session ID appears as ownerSessionId).

curl -s \
  -H "X-API-Key: $apiKey" \
  -H "Accept: application/json" \
  -H "Content-Length: 0" \
  -X PUT \
  "https://lobby-api.hivemp.com/v1/session"

After executing this method, you'll receive a connected session object that looks like this:

{
  "lobbyId": "lb-5682741632827392",
  "sessionId": "us-5658312181809152"
}

List sessions in a game lobby

You can query a list of sessions in the game lobby to find out all of the connected sessions. Since you've just joined the game lobby in the previous step, you should see your own session listed here.

The id should be the lobby ID.

curl -s \
  -H "X-API-Key: $apiKey" \
  -H "Accept: application/json" \
  -H "Content-Length: 0" \
  -X GET \
  "https://lobby-api.hivemp.com/v1/sessions"

After executing this method, you'll receive an array of connected sessions that look like this:

[
  {
    "lobbyId": "lb-5682741632827392",
    "sessionId": "us-5658312181809152"
  }
]

Your game or application should periodically poll the GET /sessions endpoint to discover when players join or leave the game lobby (and to detect if and when the game lobby is deleted).