Represents the BytroFront client, providing access to various API endpoints and utilities for interacting with the game server.

Constructors

  • Initializes the API client with a configuration object and sets up endpoint access. If the config was generated with the generateConfig method, the class's config will update automatically every 6 days

    Parameters

    • config: Record<string, any>

      A configuration object containing settings required for API communication.

    Returns BytroFront

Properties

Alliances: AllianceApi

Provides access to alliance-related API methods.

Games: GameApi

Provides access to game-related API methods.

Users: UserApi

Provides access to user-related API methods.

Util: UtilApi

Provides access to utility-related API methods and tools.

Methods

  • Sends a game-specific request to a specified game server.

    Type Parameters

    • T

      The expected return type of the response.

    Parameters

    • gameID: string

      The unique identifier of the game.

    • data: Record<string, any>

      The payload data to include in the request, including game-specific details.

    Returns Promise<T>

    A promise resolving to the response from the game server, typed as T.

    Will throw an error if the request fails or if the server returns a non-OK status.

    const response = await api.sendGameRequest<GameState>('9182721', {
    gameServer: 'xxxxxxxx.c.bytro.com',
    stateID: 2,
    option: 3,
    rights: 'chat',
    userAuth: 'hash',
    tstamp: '1982337111',
    });
    console.log(response);
  • Sends a generic request to the API server with the specified action and data payload.

    Type Parameters

    • T

      The expected return type of the response.

    Parameters

    • action: string

      The action or endpoint to call on the API server.

    • data: Record<string, any>

      The payload data to include in the request, provided as key-value pairs.

    Returns Promise<T>

    A promise resolving to the response from the server.

    Will throw an error if the request fails or if the server returns a non-OK status.

    const response = await api.sendRequest('getUserDetails', { userID: 48035824 });
    console.log(response);
  • Generates a configuration object by simulating a login process for the specified domain.

    This method uses Puppeteer to automate a browser session and interacts with the login page of the given domain. After logging in, it retrieves an iframe source, navigates to it, and extracts the configuration object from the page.

    Parameters

    • username: string

      The username to log in with.

    • password: string

      The password to log in with.

    • domain: string = "supremacy1914.com"

      The domain to target for login and configuration retrieval. Defaults to "supremacy1914.com". Examples: - "supremacy1914.com" for Supremacy 1914 (default) - "callofwar.com" for Call of War - "ironorder1919.com" for Iron Order - "supremacy1914.es" for the Spanish version of Supremacy 1914 (still allows data scrapping in other languages)

    • autoGenerate: boolean = true

      Whether to auto generate login every 6 days when being handled by BytroFront instance.

    Returns Promise<any>

    A Promise resolving to the configuration object extracted from the domain.

    An error if the iframe source cannot be located or if the configuration retrieval fails.

    const config = await generateConfig("exampleUser", "examplePass", "callofwar.com");
    console.log(config);