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:
Methods Overview
1. Get Events
Retrieve current and upcoming events in Brawl Stars.
Method:
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
2. Get Maps
Retrieve all available maps in Brawl Stars.
Method:
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) } }
3. Get Map by Brawl Stars Event ID
Retrieve a specific map using its event ID.
Method:
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 ornull
if not found.Usage Example:
val map = client.getMap(eventId) map.onSuccess { println(it?.name) }
4. Get Icons
Retrieve available icons for players and clubs.
Method:
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) }
5. Get Game Modes
Retrieve a list of game modes with detailed information.
Method:
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) } }
6. Get Game Mode by ID
Retrieve a specific game mode using its ID.
Method:
Parameters:
id
: The unique identifier for the game mode.
Returns: A
Result
containing the game mode ornull
if not found.Usage Example:
val gameMode = client.getGameMode(id) gameMode.onSuccess { println(it?.name) }