C++ SDK — Client

One Cpp Client instance per game carries your X-Api-Token and optional private key, builds endpoint URLs, serializes JSON and unwraps the success/error envelope — create it once at startup and reuse it for every call below.

Client

Constructor
Client(
    const std::string& apiToken,
    const std::string& apiPrivateToken,
    const std::string& baseUrl = "https://api.michitai.com/api",
    std::shared_ptr<ILogger> logger = nullptr
)

Initializes the SDK with API tokens and optional custom base URL and logger.

Client lifecycle and request model

One client instance carries your game's credentials and connection settings — the public X-Api-Token, the secret X-Api-Private-Token where admin calls are needed, plus the API base URL, timeouts and JSON plumbing. Construct it once at startup and share it for the process lifetime: every facade on this page borrows that configuration, so creating a client per request only re-pays connection setup.

Two credential tiers ride on the same client. Player-facing calls present the X-Game-Player-Token issued at registration; administrative calls — bans, data writes, player lists — authenticate with the token pair alone. Credentials travel in headers only, never in URLs, so they cannot leak through access logs or referrers.

  • Typed facades cover each API family; the low-level send primitive reaches any endpoint that has no facade yet.
  • API failures come back as a structured error envelope — only transport faults (DNS, timeouts, non-JSON replies) surface as transport errors.
  • Pass the player token per call rather than embedding it in the client — one client can serve every local player.
  • Calls are synchronous functions that take the client by reference — keep them off the frame-critical path in games that cannot stall, and use the typed template overloads to deserialize player data into your own structs.