dataflow.api.general_games_api¶

General API system for all haive games.

This module provides a general-purpose API that automatically discovers all available games and creates endpoints for each one, with OpenAPI documentation and game selection capabilities.

Attributes¶

Classes¶

GameInfo

Information about an available game.

GameSelectionRequest

Request for creating a new game.

GeneralGameAPI

General API system that discovers and manages all games.

Functions¶

create_general_game_api(→ tuple[fastapi.FastAPI, ...)

Create a general game API that discovers all games.

Module Contents¶

class dataflow.api.general_games_api.GameInfo(/, **data: Any)¶

Bases: pydantic.BaseModel

Information about an available game.

api_endpoints: dict[str, str] = None¶
default_models: dict[str, str] = None¶
description: str = None¶
example_configs: list[str] = None¶
game_id: str = None¶
name: str = None¶
players: list[str] = None¶
class dataflow.api.general_games_api.GameSelectionRequest(/, **data: Any)¶

Bases: pydantic.BaseModel

Request for creating a new game.

config_mode: str = None¶
example_config: str | None = None¶
game_id: str = None¶
game_settings: dict[str, Any] | None = None¶
player_configs: dict[str, Any] | None = None¶
player_models: dict[str, str] | None = None¶
class dataflow.api.general_games_api.GeneralGameAPI(app: fastapi.FastAPI, games_package: str = 'haive.games', route_prefix: str = '/api/games', ws_route_prefix: str = '/ws/games', exclude_games: list[str] | None = None)¶

General API system that discovers and manages all games.

app¶
discovered_games: dict[str, dict[str, Any]]¶
exclude_games = ['go', 'among_us']¶
game_apis: dict[str, Any]¶
games_package = 'haive.games'¶
route_prefix = '/api/games'¶
ws_route_prefix = '/ws/games'¶
dataflow.api.general_games_api.create_general_game_api(app: fastapi.FastAPI | None = None, **kwargs) tuple[fastapi.FastAPI, GeneralGameAPI]¶

Create a general game API that discovers all games.

Parameters:
  • app – Optional FastAPI app (creates one if not provided)

  • **kwargs – Additional arguments for GeneralGameAPI

Returns:

Tuple of (FastAPI app, GeneralGameAPI instance)

Examples

>>> app, game_api = create_general_game_api()
>>> # Now you have endpoints for all games!
dataflow.api.general_games_api.Agent = None¶
dataflow.api.general_games_api.BaseGameConfig = None¶
dataflow.api.general_games_api.GameAPI = None¶
dataflow.api.general_games_api.logger¶