BSApi Lib Docs 0.2.0 Help

Clubs

Clubs are essential things in Brawl Stars. On this page you will learn how get club's information, such as name, description, members and so on.

Basic usage

Here's basic usage:

val club = client.getClub(ClubTag.createUnsafe("...")) .getOrElse { throw it } // just rethrow error for our case ?: error("No such club found")

To handle Brawl Stars specific errors, please refer to Brawl Stars API Errors.

There you may get the following information:

  • tag: Club's unique tag, used to identify the club in the game.

  • name: The name of the club, visible to all players.

  • description: A brief description of the club, provided by the club owner or leader.

  • requiredTrophies: The minimum number of trophies required to join the club.

  • badgeId: The unique identifier for the club's badge, representing its visual emblem (you may retrieve actual image via Brawlify API).

  • trophies: The total number of trophies contributed by all club members.

  • type: The type of club, indicating whether it is open, closed, or requires approval to join.

  • members: A list of club members, each with detailed information:

    • tag: Unique tag identifying the player in the club.

    • name: The player's in-game name.

    • nameColor: The color of the player's name, displayed in hexadecimal format.

    • role: The player's role in the club (e.g., Member, Vice President, President).

    • trophies: The number of trophies the player has contributed to the club.

    • icon: The player's profile icon, representing their account visually.

    Learn more about data provided in the members field in 'Profiles ' topic.

Retrieving members-only

You may also get the list of members alone:

val clubMembers = client.getClubMembers(ClubTag.createUnsafe("...")) .getOrElse { throw it } // just rethrow error for our case ?: error("No such club found") clubMembers.forEach(::println)

You may also get them with pagination as in the original API:

client.getClubMembersLazily(ClubTag.createUnsafe("...")).forEachPage { if (it.isSuccess) println(it.getOrThrow()) else { println("Error happenned :( delaying it for 5000 ms") delay(5000L) } }

Learn more about pagination here.

Retrieving badge image of a club

When using Brawlify API for icons you can get the club's badge image url:

suspend fun getImageUrl( client: BrawlifyClient, badgeId: BadgeId ): BrawlifyUrl? { // retrieves all icons available on the brawlify // it's good idea to cache it on your side, because // brawlify does not provide alternative way of getting single icon. return client.getIcons() // return null on failure .getOrElse { return null } .clubsIcons // if it's a very-very new icon it might not be available .firstOrNull { id == badgeId } ?.imageUrl }

Then you may download image in any way (library does not include this functionality, because it's not needed for everyone).

Last modified: 02 January 2025