Skip to main content

A basic API wrapper for Brawl Stars.

Project description

https://raw.githubusercontent.com/Ombucha/brawlstars.py/main/banner.png PyPI version PyPI downloads Lines of code Repository size

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

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

  1. Get your API token from https://developer.brawlstars.com/

  2. Install the package as shown above.

  3. 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.

Contributing

Contributions are welcome! Please see the contributing guide.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

brawlstars_py-1.2.2.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

brawlstars_py-1.2.2-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file brawlstars_py-1.2.2.tar.gz.

File metadata

  • Download URL: brawlstars_py-1.2.2.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for brawlstars_py-1.2.2.tar.gz
Algorithm Hash digest
SHA256 1c893ffca580aed6b673740446a7a570f9205e26c352db5c7732094161ecec3e
MD5 6e161de09e5e5363b3d41c77911963d9
BLAKE2b-256 da68284e0653368ec1d534e1fb2e7f4728e66b275535f3100a33401b1866a01a

See more details on using hashes here.

File details

Details for the file brawlstars_py-1.2.2-py3-none-any.whl.

File metadata

  • Download URL: brawlstars_py-1.2.2-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for brawlstars_py-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 919a4337fba48406f0be3a2f75ee2a92fe06cd7b3ee37c1063707a26fb23ddb5
MD5 e0025445c0523b8e69dcd531c99526a0
BLAKE2b-256 6906d310cac4268a575c896cd828357a0bee8b83bb90e86c689686b1a1db58f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page