Steam link API reference
For your game server: get a link code for a player, know which Discord member matches which Steam account, what their name and roles are, and whether the member has the link role. Ready-to-adapt examples are given for Garry's Mod, FiveM, Rust, Counter-Strike 2 and SourceMod, and for Python, Node.js, PHP and cURL.
How it works
- The player types /link in game: your server calls POST /code with their SteamID64 (the one the game itself gives them) and shows them the code it gets.
- They click “Link my account” on Discord and type the code: MoBot links the two accounts and gives the chosen role. Since only the player logged in game knows the code, the link proves the same person holds both accounts.
- Your server calls POST /lookup to know whether a player is linked (and to which Discord member), what they are called on Discord, which roles they have and whether they have the link role: it can give a rank, a kit or a character name.
Player Game server MoBot API Discord
│ /link │ │ │
│──────────────────▶│ POST /code {steam_id} │ │
│ │──────────────────────────▶│ │
│ “Code K7M2QX” │ { code: "K7M2QX" } │ │
│◀──────────────────│◀──────────────────────────│ │
│ │
│ “Link my account” button + code K7M2QX ───────────────────────────────▶│
│ │ │◀── MoBot links accounts │
│ │ │ and gives the role ──▶│
│ │ POST /lookup {steam_id} │ │
│ rank / kit │──────────────────────────▶│ │
│◀──────────────────│ { linked, roles, … }◀────│ │MoBot never connects to your game server: your server calls the API (nothing to open on your firewall). To know right away that a player has just linked, your server calls /lookup again every 10 seconds while the code is valid (see the examples).
Start in 5 minutes
- In the dashboard, open the Steam link module, turn it on and choose the role(s) to give (they must be below MoBot's role).
- Pick the panel channel, save, then “Publish / update the panel”: members find the “Link my account” button there.
- Actions tab: “Generate an API key”. Copy it right away, it is shown only once.
- Test the key from a terminal with the ping command below: you should see your Discord server's name. The dashboard then shows the time of your game server's last call.
- Copy your game's example (below), put the key in your server's configuration, restart: /link gives a code in game.
curl -s -X POST https://mobot.adkynet.fr/api/v1/steam/ping -H "Authorization: Bearer mbsk_..." -H "Content-Type: application/json" -d "{}"
→ { "ok": true, "guild": { "id": "123…", "name": "Mon serveur" }, "linked_count": 0, "code_expires_in": 600, "role_ids": ["…"] }Authentication
Generate the key in the dashboard (Steam link module › Actions and lists › “Generate an API key”). It is shown only once. Send it in the Authorization header. Addresses are HTTPS.
Authorization: Bearer mbsk_<identifiant du serveur>_<48 caractères>
Content-Type: application/json
URL de base : https://mobot.adkynet.fr/api/v1/steamEvery route accepts POST with a JSON body; /lookup, /code, /links and /ping also accept GET with the fields in the URL (?steam_id=…), for servers that can only do GETs. A JSON body must always be an object { }: an empty list [ ] is refused (some libraries, like Garry's Mod's, send [ ] for an empty table).
POST /code
Gives a player a code. A new code replaces the old one. If the account is already linked, no code is created.
POST https://mobot.adkynet.fr/api/v1/steam/code
{ "steam_id": "76561198000000001" }
→ 200 { "linked": false, "code": "K7M2QX", "expires_in": 600 }
→ 200 { "linked": true, "steam_id": "7656…", "discord_id": "1234…", "linked_at": "2026-10-22T18:00:00+00:00" }The code has 6 characters, without 0, O, 1 or I (so it can be copied without mistakes), case does not matter, and its duration can be set from 2 to 60 minutes in the module (“expires_in” is in seconds). A member gets 5 tries per 10 minutes.
POST /lookup
Finds a link by SteamID64 or Discord ID, and tells whether the member is on the server, their name, their roles and whether they have the link role. Roles are IDs: copy them in Discord (right-click the role › Copy ID, with developer mode on) to match them to an in-game rank.
POST https://mobot.adkynet.fr/api/v1/steam/lookup
{ "steam_id": "76561198000000001" } (ou { "discord_id": "123456789012345678" })
→ 200 {
"linked": true, "steam_id": "…", "discord_id": "…", "linked_at": "…",
"in_server": true, "has_role": true,
"username": "alice", "display_name": "Alice",
"roles": ["555555555555555555", "777777777777777777"]
}
→ 200 { "linked": false }“has_role” is true when the member has every link role of the module. If the member left the server, “in_server” is false and “username”, “display_name” and “roles” are absent (their link is removed when they leave).
POST /unlink
Unlinks an account (for example after an in-game ban); the role is removed if the module setting asks for it.
POST https://mobot.adkynet.fr/api/v1/steam/unlink
{ "steam_id": "76561198000000001" }
→ 200 { "unlinked": true }POST /links
All the server's links, 100 per page: call again with “after” = the “next” value of the previous page.
POST https://mobot.adkynet.fr/api/v1/steam/links
{ "after": 0, "limit": 100 }
→ 200 { "links": [ { "id": 1, "steam_id": "…", "discord_id": "…", "linked_at": "…" } ], "next": 1 } (next = null à la dernière page)POST /ping
Tests the connection: if the key is right and the module is on, MoBot answers with the Discord server's name, the number of linked accounts, a code's validity and the link roles. Run it when your game server starts to spot an outdated key.
POST https://mobot.adkynet.fr/api/v1/steam/ping
{}
→ 200 { "ok": true, "guild": { "id": "123…", "name": "Mon serveur" }, "linked_count": 42, "code_expires_in": 600, "role_ids": ["555…"] }
→ 401 { "error": "invalid_key" }Finding the SteamID64
The API always expects a SteamID64: 17 digits, starting with 7656119. Here is where to get it by game; always use the one the game tells you, never an ID typed by the player.
| Game | Where to find it |
|---|---|
| Garry's Mod | ply:SteamID64() |
| FiveM | The “steam:” identifier is hexadecimal: tonumber(hex, 16) gives the SteamID64 (FiveM example below). |
| Rust (Oxide / uMod) | player.UserIDString |
| Counter-Strike 2 | player.SteamID |
| TF2, CS:GO, L4D2… | GetClientAuthId(client, AuthId_SteamID64, …) |
| Other games | Any game that exposes a player's Steam identifier (ARK, 7 Days to Die, Unturned, Project Zomboid, Squad…): look for “SteamID64” in its mod API documentation. |
| Minecraft | Minecraft does not use Steam: this link does not apply to it. |
If your game gives an older format, here is the conversion (the account ID is “Z×2 + Y” for STEAM_X:Y:Z, and the number in brackets for [U:1:N]):
SteamID64 = 76561197960265728 + identifiant de compte
STEAM_0:1:20000 → compte = 20000 × 2 + 1 = 40001 → 76561198000000001
[U:1:40001] → compte = 40001 → 76561198000000001Examples by game
Each example does the same thing: the /link command gives the player a code, and when they join the server reads their link. Replace the “mbsk_…” key with your Discord server's, and keep it in your game server's configuration, never in a file you share.
/link gives a code, then the server watches for the link every 10 seconds; on join, the rank is given from the Discord role. Adapt SetUserGroup to your rank system (ULX, SAM, ServerGuard…).
Where? A server-side Lua file: garrysmod/addons/mobot_link/lua/autorun/server/mobot_link.lua. · Example to adapt to your server: it follows the game's documentation but could not be run in game.
-- garrysmod/addons/mobot_link/lua/autorun/server/mobot_link.lua
local API = "https://mobot.adkynet.fr/api/v1/steam"
-- La clé est dans garrysmod/data/mobot_key.txt (une ligne) : jamais dans un addon que tu partages
local KEY = string.Trim(file.Read("mobot_key.txt", "DATA") or "")
-- Rôle Discord (identifiant) -> groupe en jeu : remplace SetUserGroup par l'appel de ULX, SAM, ServerGuard…
local GROUPS = {
["123456789012345678"] = "vip",
["234567890123456789"] = "moderator",
}
local function call(action, body, done)
HTTP({
url = API .. "/" .. action,
method = "POST",
type = "application/json",
body = util.TableToJSON(body), -- toujours au moins un champ : une table vide serait envoyée comme [] au lieu de {}
headers = { Authorization = "Bearer " .. KEY },
success = function(status, response) done(status, util.JSONToTable(response) or {}) end,
failed = function(reason) print("[MoBot] API injoignable : " .. tostring(reason)) end,
})
end
-- Donne au joueur le grade de son rôle Discord le plus haut dans la liste GROUPS
local function apply(ply, data)
if not (data.linked and data.in_server) then return end
ply:SetNWString("discord_id", data.discord_id)
ply:SetNWString("discord_name", data.display_name or "")
for _, roleId in ipairs(data.roles or {}) do
if GROUPS[roleId] then
ply:SetUserGroup(GROUPS[roleId])
break
end
end
end
-- /link : un code à taper sur Discord, puis on guette la liaison (un appel toutes les 10 s pendant la validité du code)
hook.Add("PlayerSay", "MoBotLink", function(ply, text)
if string.lower(string.Trim(text)) ~= "/link" then return end
if (ply.mobotNext or 0) > CurTime() then
ply:ChatPrint("Patiente quelques secondes avant de redemander un code.")
return ""
end
ply.mobotNext = CurTime() + 5
local steamId = ply:SteamID64()
call("code", { steam_id = steamId }, function(status, data)
if not IsValid(ply) then return end
if data.linked then
ply:ChatPrint("Ton compte est déjà lié.")
elseif data.code then
ply:ChatPrint("Ton code : " .. data.code .. " (valable " .. math.floor(data.expires_in / 60) .. " min). Clique sur « Lier mon compte » dans Discord.")
local timerName = "mobot_wait_" .. steamId
timer.Create(timerName, 10, math.floor(data.expires_in / 10), function()
if not IsValid(ply) then timer.Remove(timerName) return end
call("lookup", { steam_id = steamId }, function(_, found)
if found.linked and IsValid(ply) then
timer.Remove(timerName)
ply:ChatPrint("Compte lié, merci !")
apply(ply, found)
end
end)
end)
else
ply:ChatPrint("MoBot n'a pas répondu (" .. tostring(status) .. "), réessaie plus tard.")
end
end)
return ""
end)
-- À la connexion : le joueur est-il lié, et quel est son grade ?
hook.Add("PlayerAuthed", "MoBotCheck", function(ply)
call("lookup", { steam_id = ply:SteamID64() }, function(_, data)
if IsValid(ply) then apply(ply, data) end
end)
end)Good practice
- Never trust a SteamID the player tells you: take the one the game knows. That is what makes the link reliable.
- Call the API from your server, never from the player's client: the key would give access to all of the server's links.
- Keep the /lookup result for a few minutes (per player) rather than asking again on every action: the API accepts about 300 calls per minute.
- While waiting for a link, one call every 10 seconds per player is enough; stop asking when the code expires (“expires_in”).
- Handle failures: if the API does not answer (503) or you are rate-limited (429), the game must keep working and retry later without blocking the player.
- If the key leaked: “Revoke the API key” (or generate a new one) in the dashboard cuts it immediately. Links already made stay.
Troubleshooting
| Symptom | Likely cause and fix |
|---|---|
| 401 invalid_key | Wrong key, copied with a space or line break, revoked and replaced, or module off. The answer is the same in every case, for security: run /ping, check the module is on, and generate the key again if needed. |
| 400 invalid_steam_id | The SteamID is not 17 digits. On FiveM, the hexadecimal identifier was sent: convert it to decimal. |
| 400 invalid_request | The body is not a JSON object (an empty list [ ] for example), or a field is malformed. |
| 429 rate_limited | Too many calls: cache the answers and wait the number of seconds in the Retry-After header. |
| “Invalid or expired code” on Discord | The code expired, or a newer code replaced it (only the latest works). Letters can be typed in lowercase; 0, O, 1 and I do not exist in codes. |
| The role is not given | The role is above MoBot's in the role list, or MoBot lacks “Manage roles”. Move MoBot's role above it; the Diagnostic page checks this. |
| has_role: false | The member does not (or no longer) have every link role: they are only given at link time, and removed on unlink if the setting asks for it. |
| linked: false | The player has not linked yet, was unlinked (by themselves, by the team, or by leaving the Discord server), or it is not the same SteamID64. |
| No answer at all | The game server cannot reach the site over HTTPS (outbound firewall, old TLS library, server without Internet access). Try the cURL command from the same machine. |
Errors and limits
401 invalid_key— key missing, wrong, revoked, or module disabled (same reply in every case).400 invalid_request / invalid_steam_id / invalid_json— malformed field: a SteamID64 is 17 digits.429 rate_limited— too many requests (Retry-After header). About 300 per minute per address.503 unavailable— MoBot is temporarily unreachable: retry.