Python Game Server Client SDK

This is the Python version of the Agones Game Server Client SDK.

Check the Client SDK Documentation for more details on each of the SDK functions and how to run the SDK locally.

SDK Functionality

Area Action Implemented
Lifecycle Ready ✔️
Lifecycle Health ✔️
Lifecycle Reserve ✔️
Lifecycle Allocate ✔️
Lifecycle Shutdown ✔️
Configuration GameServer ✔️
Configuration Watch ✔️
Metadata SetAnnotation ✔️
Metadata SetLabel ✔️
Counters GetCounterCount ✔️
Counters SetCounterCount ✔️
Counters IncrementCounter ✔️
Counters DecrementCounter ✔️
Counters SetCounterCapacity ✔️
Counters GetCounterCapacity ✔️
Lists AppendListValue ✔️
Lists DeleteListValue ✔️
Lists SetListCapacity ✔️
Lists GetListCapacity ✔️
Lists ListContains ✔️
Lists GetListLength ✔️
Lists GetListValues ✔️
Player Tracking GetConnectedPlayers ✔️
Player Tracking GetPlayerCapacity ✔️
Player Tracking GetPlayerCount ✔️
Player Tracking IsPlayerConnected ✔️
Player Tracking PlayerConnect ✔️
Player Tracking PlayerDisconnect ✔️
Player Tracking SetPlayerCapacity ✔️

Prerequisites

Installation

pip install agones

Or install from source:

pip install -e sdks/python

Usage

To begin working with the SDK, create an instance and connect to the sidecar.

from agones import AgonesSDK

sdk = AgonesSDK()
sdk.connect()

A context manager is also supported:

with AgonesSDK() as sdk:
    sdk.ready()
    # game logic

To send a health check ping, call sdk.health(). This should be called periodically in a background thread.

import threading
import time

def health_loop():
    while True:
        sdk.health()
        time.sleep(2)

threading.Thread(target=health_loop, daemon=True).start()

To mark the game session as ready call sdk.ready().

sdk.ready()

To mark that the game session is completed and the game server should be shut down call sdk.shutdown().

sdk.shutdown()

To mark the game server as reserved for a period of time, call sdk.reserve(seconds).

sdk.reserve(30)

To set a Label on the backing GameServer call sdk.set_label(key, value).

sdk.set_label("test-label", "test-value")

To set an Annotation on the backing GameServer call sdk.set_annotation(key, value).

sdk.set_annotation("test-annotation", "test value")

To get details of the backing GameServer call sdk.get_game_server().

gameserver = sdk.get_game_server()
print(f"Name: {gameserver.object_meta.name}")
print(f"State: {gameserver.status.state}")

To get updates on the backing GameServer as they happen, call sdk.watch_game_server(callback).

This will watch for updates in a background daemon thread and call the provided callback on each update.

def on_update(gameserver):
    print(f"GameServer update, state: {gameserver.status.state}")

sdk.watch_game_server(on_update)

For more information, please read the SDK Overview, check out the Python SDK implementation .


Last modified April 14, 2026: fix: improve health ping handling in AgonesSDK (d056ef0)