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.

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([app])

Create a general game API that discovers all games.

Module Contents¶

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

Bases: pydantic.BaseModel

Information about an available game.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

class dataflow.api.general_games_api.GameSelectionRequest(/, **data)¶

Bases: pydantic.BaseModel

Request for creating a new game.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

class dataflow.api.general_games_api.GeneralGameAPI(app, games_package='haive.games', route_prefix='/api/games', ws_route_prefix='/ws/games', exclude_games=None)¶

General API system that discovers and manages all games.

Initialize the general game API.

Parameters:
  • app (fastapi.FastAPI) – FastAPI application

  • games_package (str) – Package to scan for games

  • route_prefix (str) – Prefix for REST routes

  • ws_route_prefix (str) – Prefix for WebSocket routes

  • exclude_games (list[str] | None) – List of game names to exclude

dataflow.api.general_games_api.create_general_game_api(app=None, **kwargs)¶

Create a general game API that discovers all games.

Parameters:
  • app (fastapi.FastAPI | None) – Optional FastAPI app (creates one if not provided)

  • **kwargs – Additional arguments for GeneralGameAPI

Returns:

Tuple of (FastAPI app, GeneralGameAPI instance)

Return type:

tuple[fastapi.FastAPI, GeneralGameAPI]

Examples

>>> app, game_api = create_general_game_api()
>>> # Now you have endpoints for all games!