BSApi Lib Docs 0.2.0 Help

Brawlify API

The BrawlifyClient is a Kotlin-based client for interacting with the Brawlify API. It provides access to various Brawl Stars data such as events, maps, icons, and game modes. This client simplifies making HTTP requests to the API, handling JSON parsing, and providing a type-safe interface for developers. In addition, both Brawl Stars API and Brawlify API share some of the entities, like EventId.

Creating an Instance of BrawlifyClient

To use the BrawlifyClient, you'll need an HttpClientEngine. You can also customize the JSON deserialization behavior and HTTP client configuration if necessary. Here's an example of how to create an instance:

import io.ktor.client.engine.cio.CIO import kotlinx.serialization.json.Json val client = BrawlifyClient( engine = CIO, // not all fields are included in API due to // lack of information about them (for example, some of them // are null in any case) // in addition, for forward compatibility it's always good // to have it json = Json { ignoreUnknownKeys = true }, configBlock = { // Additional HttpClient configuration here } )

Methods Overview

1. Get Events

Retrieve current and upcoming events in Brawl Stars.

Method:

suspend fun getEvents(): Result<GetEventsResponse>
  • Returns: A Result containing the response with active and upcoming events or an error.

  • Usage Example:

    val events = client.getEvents() events.onSuccess { println(it.active) } // prints active events

API Documentation

2. Get Maps

Retrieve all available maps in Brawl Stars.

Method:

suspend fun getMaps(): Result<List<BrawlifyMap>>
  • Returns: A Result containing a list of maps or an error.

  • Usage Example:

    val maps = client.getMaps() maps.onSuccess { it.forEach { map -> println(map.name) } }

API Documentation

3. Get Map by Brawl Stars Event ID

Retrieve a specific map using its event ID.

Method:

suspend fun getMap(eventId: EventId): Result<BrawlifyMap?>
  • Parameters:

    • eventId: The unique identifier for the event that can be obtained via Brawl Stars API (battles list, events rotation) or via Brawlify API itself.

  • Returns: A Result containing the map or null if not found.

  • Usage Example:

    val map = client.getMap(eventId) map.onSuccess { println(it?.name) }

API Documentation

4. Get Icons

Retrieve available icons for players and clubs.

Method:

suspend fun getIcons(): Result<GetIconsResponse>
  • Returns: A Result containing icons for players and clubs.

  • Usage Example:

    val icons = client.getIcons() icons.onSuccess { println(it.playersIcons.size) println(it.clubsIcons.size) }

API Documentation

5. Get Game Modes

Retrieve a list of game modes with detailed information.

Method:

suspend fun getGameModes(): Result<List<BrawlifyFullGameMode>>
  • Returns: A Result containing a list of game modes or an error.

  • Usage Example:

    val gameModes = client.getGameModes() gameModes.onSuccess { it.forEach { mode -> println(mode.name) } }

API Documentation

6. Get Game Mode by ID

Retrieve a specific game mode using its ID.

Method:

suspend fun getGameMode(id: BrawlifyGameModeId): Result<BrawlifyFullGameMode?>
  • Parameters:

    • id: The unique identifier for the game mode.

  • Returns: A Result containing the game mode or null if not found.

  • Usage Example:

    val gameMode = client.getGameMode(id) gameMode.onSuccess { println(it?.name) }

API Documentation

Last modified: 02 January 2025