Skip to main content

Players

Listing players

Players can be listed on /api/players endpoint:

GET /api/players
[
{
"_id": "it6hQu3YDsSNFSKV",
"firstName": "John",
"lastName": "Smith",
"username": "ProPlayer",
"avatar": "iVBORw0K...",
"country": "PL",
"game": "cs2",
"steamid": "768XXXXXXXXX",
"team": "team_id",
"extra": {}
}
]

If only a few players are needed, this method can be filtered by passing steamids query, which should be in form of identifiers joined with ;, so it is possible to filter all players but two with this request:

index.ts
fetch("http://localhost:1349/api/players?steamids=STEAMID_1;STEAMID_2");
info

About avatars: Currently, LHM sends back information with avatars represented as URLs in the local network: http://192.168.50.71:1349/api/players/avatar/ahoYtSlIjhYfI7L3 would be an example. This sometimes causes issues on PCs with some stricter antiviruses. In the future avatars will be sent as relative address instead, to mitigate this.

Adding a player

Easiest way to create player through LHM API is a simple POST request to /api/players:

POST /api/players
{
"firstName": "John",
"lastName": "Smith",
"username": "ProPlayer",
"avatar": "iVBORw0K...",
"country": "PL",
"steamid": "768XXXXXXXXX",
"team": "team_id",
"extra": {}
}
FieldDescription
firstNameThe first name of the player.
lastNameThe last name of the player.
usernameThe username of the player.
avatarThe avatar image of the player in base64 format with metadata removed., so it can't have data:base64;image/png
countryThe country code of the player in ISO format.
steamidThe identifier of the player.
teamThe ID of the team the player belongs to.
extraA record object with string keys and values for additional player metadata.

All fields can be empty strings (beside extra field), steamid however is required for player identification. For more details check Player Identification section.

Player is automatically assigned to a game that LHM is currently set to.

Modifying a Player

To modify an existing player, send a PATCH request to /api/players/:id:

PATCH /api/players/:id
{
"firstName": "John",
"lastName": "Smith",
"username": "ProPlayer",
"avatar": "iVBORw0K...",
"country": "PL",
"steamid": "768XXXXXXXXX",
"team": "team_id",
"extra": {}
}

All of the fields are identical as in the adding player section

Removing a Player

To remove an existing player, send a DELETE request to /api/players/:id. You can also remove multiple players in one request by joining their IDs with a semicolon (;).

Example:

DELETE /api/players/123;456;789

This will remove the players with _id 123, 456, and 789.

Player Identification

For HUDs to map customized data to in-game player entity, a common identifier must be set up. For legacy reasons this field is named steamid, and connects world of LHM with world of the game, so it doesn't always mean "ID of Steam Account", as it might also mean just "in-game username", when we don't have access to other identification methods. You can see which game uses which method in the list below.

SteamID means SteamID64, Steam Community URL or Steam Vanity URL (if Steam API key is provided in the LHM settings), while Name will mean in-game (displayed) name.

  • CS2 / CSGO - SteamID
  • Dota 2 - SteamID
  • League of Legends - Name
  • Rocket League - Name
  • Apex Legends - Name

Example of LHM SteamIDs conversion:

https://steamcommunity.com/id/osztenkurden -> 76561198029090368
https://steamcommunity.com/profiles/76561198029090368 -> 76561198029090368

Fetching Avatars

It's possible to get player uploaded avatar in two ways. Both will result in image being served as normal, browser asset.

By passing _id:

http://localhost:1349/api/players/avatar/:id

By passing steamid:

http://localhost:1349/api/players/avatar/steamid/:id