A fundamental wrapper for the Brawl Stars API covering all endpoints and including many features!
Project description
BStats
- This wrapper supports both sync and async requests to the Brawl Stars API
- Required Python versions: 3.8 and higher
Features
- Easy to use with an object oriented design.
- Get a player's profile as well as their 25 most recent battles.
- Get a club's statistics as well as its members and their individual statistics.
- Get the top 200 rankings for players, clubs, or a specific brawler.
- Get information about all currently available brawlers.
- Get the current ongoing event rotation.
Installation
Install the latest build:
pip install bstats
Examples
Sync example
import bstats
client = bstats.SyncClient("token") # Never post any of your tokens for APIs on a public github!
player = client.get_player("80V2R98CQ")
print(player.trophies)
print(player.solo_victories)
club = player.club
if club:
print(club.tag)
members = club.members
for player in members[:5]: # Get the top 5 club members
print(player.name, player.trophies) # Show their name and their trophies
# Get the top 5 players in the world
best_players = client.get_leaderboards(mode="players", limit=5)
for player in best_players:
print(player.name, player.rank) # Show their name and their rank on the leaderboard
# Get the top 5 Meg players in the United Kingdom
top_meg_players = client.get_leaderboards(
mode="brawlers",
country="GB",
limit=5,
brawler="Meg"
)
for player in top_meg_players:
print(player.name, player.rank)
# Get a player's 25 most recent battles
battles = client.get_battlelogs("80V2R98CQ")
print(battles[0].mode_name) # Show the last mode the player battled in
rotation = client.get_event_rotation()
for event in rotation:
print(event.start, event.end)
Async example
import asyncio
import bstats
client = bstats.AsyncClient("token") # Never post any of your tokens for APIs on a public github!
# to use the async client, we'll need an async function
async def main():
player = await client.get_player("80V2R98CQ")
print(player.trophies)
print(player.solo_victories)
club = player.club
if club:
print(club.tag)
members = club.members
for player in members[:5]: # Get the top 5 club members
print(player.name, player.trophies) # Show their name and their trophies
# Get the top 5 players in the world
best_players = await client.get_leaderboards(mode="players", limit=5)
for player in best_players:
print(player.name, player.rank) # Show their name and their rank on the leaderboard
# Get the top 5 Meg players in the United Kingdom
top_meg_players = await client.get_leaderboards(
mode="brawlers",
country="GB",
limit=5,
brawler="Meg"
)
for player in top_meg_players:
print(player.name, player.rank)
# Get a player's 25 most recent battles
battles = await client.get_battlelogs("80V2R98CQ")
print(battles[0].mode_name) # Show the last mode the player battled in
rotation = await client.get_event_rotation()
for event in rotation:
print(event.start, event.end)
# we now create a loop to send us the data from the async client
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Miscellaneous
- Please star this repository if you're satisfied with the wrapper 😊
- Have you come across an issue in the wrapper? No worries! Just create an issue!
- If you need an API key, visit the Brawl Stars API page.
- (You must create an account in order to create and use an API key)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bstats-1.1.2.tar.gz
(16.3 kB
view details)
Built Distribution
bstats-1.1.2-py3-none-any.whl
(26.4 kB
view details)
File details
Details for the file bstats-1.1.2.tar.gz
.
File metadata
- Download URL: bstats-1.1.2.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ce382e405d1d7e9e08987074caf612df0c3cfa04724c88838c6e03f569d7c1a |
|
MD5 | 8919da32d705bb586d0240537b41c2e2 |
|
BLAKE2b-256 | 83b20cec50ddf5236ef4e8950cf7b0f6f783b36455ae1966f3ff282a984451a0 |
File details
Details for the file bstats-1.1.2-py3-none-any.whl
.
File metadata
- Download URL: bstats-1.1.2-py3-none-any.whl
- Upload date:
- Size: 26.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cffa69d9e5e02f97eafc3043864f3b998d31059c4617391bef61f3964b713d5a |
|
MD5 | 11ab2a157426e211c6ea6684ffdcf067 |
|
BLAKE2b-256 | 37d7f4bbf65caa6307f30da50c8fcf9d3d334338d36bf79a593783bc75198af8 |