Game Rooms API

Game Rooms

POST
/api/game_room.php/create
Create game room (requires API TOKEN, PLAYER TOKEN)
POST
/api/game_room.php/list
List all game rooms (requires API TOKEN)
POST
/api/game_room.php/{ID}/join
Join existing room (requires API TOKEN, PLAYER TOKEN)
GET
/api/game_room.php/players
List all players in current room (requires API TOKEN, PLAYER TOKEN)
POST
/api/game_room.php/leave
Leave current game room (requires API TOKEN, PLAYER TOKEN)
POST
/api/game_room.php/heartbeat
Send room heartbeat (requires API TOKEN, PLAYER TOKEN)
POST
/api/game_room.php/actions
Submit game action (requires API TOKEN, PLAYER TOKEN)
GET
/api/game_room.php/actions/poll
Get actions result (requires API TOKEN, PLAYER TOKEN)
GET
/api/game_room.php/actions/pending
View all pending actions (requires API TOKEN, PLAYER TOKEN)
POST
/api/game_room.php/actions/{ID}/complete
Complete or reject action (requires API TOKEN, PLAYER TOKEN)
POST
/api/game_room.php/updates
Send updates to players (requires API TOKEN, PLAYER TOKEN)
POST
/api/game_room.php/updates/poll
Poll for updates (requires API TOKEN, PLAYER TOKEN)
GET
/api/game_room.php/current
Get current room status (requires API TOKEN, PLAYER TOKEN)
POST
/api/game_room.php/stop
Stop game room (Host Only) (requires API TOKEN, PLAYER TOKEN)
POST
/api/game_room.php/kick
Kick player from game room (Host Only) (requires API TOKEN, PLAYER TOKEN)
POST
/api/game_room.php/password
Update room password (Host Only) (requires API TOKEN, PLAYER TOKEN)
POST /api/game_room.php/create
Request:
$ curl -X POST "/api/game_room.php/create" \
  -H "X-Api-Token: API_TOKEN" \
  -H "X-Game-Player-Token: PLAYER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "room_name": "My Game Room",
    "max_players": 4,
    "password": "secret123",
    "host_switch": false,
    "can_leave_room": true,
    "player_data": {
      "level": 15,
      "class": "warrior",
      "inventory": ["sword", "shield"]
    }
  }'
Response:
{
  "success": true,
  "room_id": "dc3723848639139113ca240958ba0bf8",
  "room_name": "My Game Room",
  "is_host": true
}
POST /api/game_room.php/list
Request:
$ curl -X POST "/api/game_room.php/list" \
  -H "X-Api-Token: API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "search": "",
    "limit": 20
  }'
Response:
{
  "success": true,
  "rooms": [
    {
      "room_id": "dc3723848639139113ca240958ba0bf8",
      "room_name": "My Game Room",
      "max_players": 4,
      "current_players": 1,
      "has_password": 1
    }
  ]
}
Note: max_players in response can be between 2 and 16
POST /api/game_room.php/ROOM_ID/join
Request:
$ curl -X POST "/api/game_room.php/dc3723848639139113ca240958ba0bf8/join" \
  -H "X-Api-Token: API_TOKEN" \
  -H "X-Game-Player-Token: PLAYER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "password": "secret123"
  }'
Response:
{
  "success": true,
  "room_id": "dc3723848639139113ca240958ba0bf8",
  "message": "Successfully joined the room"
}
GET /api/game_room.php/players
Request:
$ curl -X GET "/api/game_room.php/players" \
  -H "X-Api-Token: API_TOKEN" \
  -H "X-Game-Player-Token: PLAYER_TOKEN"
Response:
{
  "success": true,
  "players": [
    {
      "player_id": "48",
      "player_name": "TestPlayer",
      "is_host": 1,
      "is_online": 1,
      "is_local": true,
      "last_heartbeat": "2026-03-09 09:39:34"
    },
    {
      "player_id": "49",
      "player_name": "TestPlayer",
      "is_host": 0,
      "is_online": 1,
      "is_local": false,
      "last_heartbeat": "2026-03-09 09:44:39"
    }
  ],
  "last_updated": "2026-03-09T09:56:21+00:00"
}
POST /api/game_room.php/leave
Request:
$ curl -X POST "/api/game_room.php/leave" \
  -H "X-Api-Token: API_TOKEN" \
  -H "X-Game-Player-Token: PLAYER_TOKEN"
Response:
{
  "success": true,
  "message": "Successfully left the room"
}
POST /api/game_room.php/actions
Request (send to host):
$ curl -X POST "/api/game_room.php/actions" \
  -H "X-Api-Token: API_TOKEN" \
  -H "X-Game-Player-Token: PLAYER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "target_players": "host",
    "action_type": "move",
    "request_data": {
      "x": 10,
      "y": 20
    }
  }'
Response:
{
  "success": true,
  "actions_sent": 1,
  "action_ids": ["1c2bbd859e36dc7d7e5e9b4f263c88ce"],
  "target_players_ids": [48]
}
GET /api/game_room.php/actions/poll
Request:
$ curl "/api/game_room.php/actions/poll"
Response:
{
  "success": true,
  "actions": [
    {
      "action_id": "efc5ea74e3a37e41a4f57d948cfb2538",
      "action_type": "move",
      "response_data": {
        "success": true,
        "message": "Moved successfully"
      },
      "status": "completed",
      "target_id": 48,
      "is_host": true,
      "processed_at": "2026-03-13T10:15:30+00:00"
    }
  ]
}
GET /api/game_room.php/actions/pending
Request:
$ curl "/api/game_room.php/actions/pending"
Response:
{
  "success": true,
  "actions": [
    {
      "action_id": "efc5ea74e3a37e41a4f57d948cfb2538",
      "player_id": 49,
      "target_id": 48,
      "action_type": "move",
      "request_data": {
        "x": 10,
        "y": 20
      },
      "created_at": "2026-03-09 10:10:10",
      "player_name": "TestPlayer",
      "is_host": false
    }
  ]
}
POST /api/game_room.php/actions/ACTION_ID/complete
Request:
$ curl -X POST "/api/game_room.php/actions/1c2bbd859e36dc7d7e5e9b4f263c88ce/complete" \
  -H "X-Api-Token: API_TOKEN" \
  -H "X-Game-Player-Token: PLAYER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "status": "completed",
    "response_data": {
      "success": true,
      "message": "Moved successfully"
    }
  }'
Response:
{
  "success": true,
  "message": "Action completed"
}
POST /api/game_room.php/updates
Request:
$ curl -X POST "/api/game_room.php/updates" \
  -H "X-Api-Token: API_TOKEN" \
  -H "X-Game-Player-Token: PLAYER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "target_players": "all",
    "type": "play_animation",
    "data": {
      "animation": "victory",
      "duration": 2.0
    }
  }'
Response:
{
  "success": true,
  "updates_sent": 1,
  "update_ids": ["ddb19c9d8722073762f5db33ff13712a"],
  "target_players_ids": [47]
}
POST /api/game_room.php/updates
Request:
$ curl -X POST "/api/game_room.php/updates" \
  -H "X-Api-Token: API_TOKEN" \
  -H "X-Game-Player-Token: PLAYER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "target_players": "specific",
    "target_players_ids": [47],
    "type": "spawn_effect",
    "data": {
      "effect": "explosion",
      "position": {
        "x": 10,
        "y": 20
      }
    }
  }'
Response:
{
  "success": true,
  "updates_sent": 1,
  "update_ids": ["377bfa1d4c56c3f72d9c87b0c081e6e8"],
  "target_players_ids": [47]
}
POST /api/game_room.php/updates/poll
Request:
$ curl -X POST "/api/game_room.php/updates/poll" \
  -H "X-Api-Token: API_TOKEN" \
  -H "X-Game-Player-Token: PLAYER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "from_players": "host",
    "last_update": null
  }'
Response:
{
  "success": true,
  "updates": [
    {
      "update_id": "a28388775fcf9478c6926cbe44f9d3ed",
      "from_player_id": "48",
      "type": "play_animation",
      "data": {
        "animation": "victory",
        "duration": 2
      },
      "created_at": "2026-03-09 10:51:40"
    },
    {
      "update_id": "f26cbcdab3939b968f148edf68a9fe54",
      "from_player_id": "48",
      "type": "play_animation",
      "data": {
        "animation": "victory",
        "duration": 2
      },
      "created_at": "2026-03-09 10:53:58"
    },
    {
      "update_id": "374ad8d18f1a1fddf09a856d61787c5c",
      "from_player_id": "48",
      "type": "play_animation",
      "data": {
        "animation": "victory",
        "duration": 2
      },
      "created_at": "2026-03-09 10:54:16"
    }
  ],
  "last_update": "374ad8d18f1a1fddf09a856d61787c5c"
}
POST /api/game_room.php/updates/poll
Request:
$ curl -X POST "/api/game_room.php/updates/poll" \
  -H "X-Api-Token: API_TOKEN" \
  -H "X-Game-Player-Token: PLAYER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "from_players": "host",
    "last_update": "a28388775fcf9478c6926cbe44f9d3ed"
  }'
Response:
{
  "success": true,
  "updates": [
    {
      "update_id": "f26cbcdab3939b968f148edf68a9fe54",
      "from_player_id": "48",
      "type": "play_animation",
      "data": {
        "animation": "victory",
        "duration": 2
      },
      "created_at": "2026-03-09 10:53:58"
    }
  ],
  "last_update": "f26cbcdab3939b968f148edf68a9fe54"
}
GET /api/game_room.php/current
Request:
$ curl "/api/game_room.php/current"
Response:
{
  "success": true,
  "in_room": true,
  "room": {
    "room_id": "05f157893b1237f7699e548d045904ab",
    "room_name": "Game from Matchmaking 636b3f",
    "is_host": false,
    "is_online": true,
    "max_players": 4,
    "current_players": 2,
    "has_password": false,
    "is_active": true,
    "player_name": "TestPlayer",
    "joined_at": "2026-03-06 17:50:35",
    "last_heartbeat": "2026-03-06 18:02:35",
    "room_created_at": "2026-03-06 17:50:35",
    "room_last_activity": "2026-03-06 18:04:58"
  },
  "pending_actions": [],
  "pending_updates": []
}
POST /api/censor.php
Request:
$ curl -X POST "/api/censor.php" \
  -H "X-Api-Token: API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "message a player wants to display"
  }'
Response (clean text):
{
  "success": true,
  "clean": true,
  "filtered": "message a player wants to display"
}
Response (flagged text — filtered is the masked, display-safe version):
{
  "success": true,
  "clean": false,
  "filtered": "********"
}

Body field text (string, max 1000 UTF-8 characters). Requires API TOKEN only — no player session. Rate-limited per game + IP. The local SDK TextFilter gives instant offline screening; this endpoint stays authoritative — a missed local flag still fails server-side.

ERROR Invalid API Token
Request:
$ curl -X POST "/api/game_players.php/register" \
  -H "X-Api-Token: INVALID_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "player_name": "TestPlayer"
  }'
Response:
{
  "success": false,
  "error": "Invalid API token",
  "message": "Authentication failed"
}