A modern, and easy-to-use Python wrapper for the official Brawl Stars API.
Features
Full coverage of the Brawl Stars API
Simple, Pythonic interface
Type hints for better editor support
Built-in rate limit handling
Pagination and filtering helpers
Extensive documentation and examples
Requirements
Python 3.8 or higher
Installation
To install the latest stable version:
# Unix / macOS
python3 -m pip install "brawlstars.py"
# Windows
py -m pip install "brawlstars.py"
To install the development version:
git clone https://github.com/Ombucha/brawlstars.py
cd brawlstars.py
python3 -m pip install -e .
Getting Started
Get your API token from https://developer.brawlstars.com/
Install the package as shown above.
Start coding!
Quick Example
import brawlstars as bs
client = bs.Client("token")
# Fetch player info
player = client.get_player("#9PPUP2CJ")
print(f"{player.name}: {player.trophies} trophies, {player.team_victories} team victories")
# Fetch club info and best player
club = client.get_club(player.club.tag)
if club:
members = client.get_club_members(club.tag)
best_player = max(members, key=lambda m: m.trophies)
print(f"Best club member: {best_player.name} - {best_player.trophies} 🏆")
# Top 5 global players
for player in client.get_player_rankings("global", limit=5):
print(f"{player.rank}. {player.name} ({player.trophies} 🏆)")
# Top 10 US players for a specific brawler
for player in client.get_brawler_rankings("us", 16000043, limit=10):
print(f"{player.rank}. {player.name} ({player.trophies} 🏆)")
# Recent battles
battles = client.get_player_battlelog("#JGCCGY80")
print("Most recent battle mode:", battles[0].battle.mode)
Advanced Usage
Pagination: Use limit and after/before parameters for large result sets.
Error Handling: All API errors raise brawlstars.BrawlStarsException or subclasses.
Rate Limiting: The client automatically handles rate limits and retries.
Custom Session: Pass your own requests.Session for advanced usage.
Links
Contributing
Contributions are welcome! Please see the contributing guide.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Metadata
Release files for brawlstars.py 1.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| brawlstars_py-1.2.2.tar.gz | 10.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| brawlstars_py-1.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.9 kB
Release files / brawlstars_py-1.2.2.tar.gz
| Download URL | brawlstars_py-1.2.2.tar.gz |
|---|---|
| Size | 10.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1c893ffca580aed6b673740446a7a570f9205e26c352db5c7732094161ecec3e
|
|
BLAKE2b-256 checksum How to use checksums |
da68284e0653368ec1d534e1fb2e7f4728e66b275535f3100a33401b1866a01a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.23
|
Release files / brawlstars_py-1.2.2-py3-none-any.whl
| Download URL | brawlstars_py-1.2.2-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
919a4337fba48406f0be3a2f75ee2a92fe06cd7b3ee37c1063707a26fb23ddb5
|
|
BLAKE2b-256 checksum How to use checksums |
6906d310cac4268a575c896cd828357a0bee8b83bb90e86c689686b1a1db58f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.23
|