Skip to main content

Unofficial Python wrapper for the Brawl Stars API.

Project description

NovaBrawlStarsApi

A Python library to easily interact with the Brawl Stars API and fetch player information.

Features

  • Retrieve detailed player information
  • Supports multiple player tags
  • Easy Python integration
  • Secure API key management with .env

Installation

You can install NovaBrawlStarsApi via pip:

pip install novabrawlstars

Or clone the repo and installation dependencies manually:

git clone https://github.com/NovaFenice/NovaBrawlStarsApi.git
cd NovaBrawlStarsApi

Usage

How to get players info

from novabrawlstars.client import NovaBrawlStars
import os
import asyncio
from dotenv import load_dotenv

load_dotenv()

async def main():
    api_bs = os.getenv("api_bs") # Your Brawl Stars API token
    tag_p1 = os.getenv("tag_p1") # Brawl Stars Player tag (es. #12345678 or 12345678)
    nb = NovaBrawlStars(api_bs) # Initialize the Brawl Stars API client
    
    async with nb as client:
        player = await client.get_player(tag_p1)  # Get a Player object from the API

    await nb.close() # Close the HTTP client session

if __name__ == "__main__":
    asyncio.run(main()) # Run the main function

How to get battlelog info

from novabrawlstars.client import NovaBrawlStars
import os
import asyncio
from dotenv import load_dotenv

load_dotenv()

async def main():
    api_bs = os.getenv("api_bs") # Your Brawl Stars API token
    tag_p1 = os.getenv("tag_p1") # Brawl Stars Player tag (es. #12345678 or 12345678)
    nb = NovaBrawlStars(api_bs) # Initialize the Brawl Stars API client
    
    async with nb as client:
        player_battlelog = await client.get_battlelog(tag_p1)  # Get a BattleLogListType object from the API

    await nb.close() # Close the HTTP client session

if __name__ == "__main__":
    asyncio.run(main()) # Run the main function

How to get club info

from novabrawlstars.client import NovaBrawlStars
import os
import asyncio
from dotenv import load_dotenv

load_dotenv()

async def main():
    api_bs = os.getenv("api_bs") # Your Brawl Stars API token
    tag_p1 = os.getenv("tag_p1") # Brawl Stars Player tag (es. #12345678 or 12345678)
    nb = NovaBrawlStars(api_bs) # Initialize the Brawl Stars API client
    
    async with nb as client:
        player = await client.get_player(tag_p1)  # Get a BattleLogListType object from the API
        club = await client.get_player_club(player.club.tag) # Get a Club object passing the player 

    await nb.close() # Close the HTTP client session

if __name__ == "__main__":
    asyncio.run(main()) # Run the main function

How to get club members info using pagination

from novabrawlstars.client import NovaBrawlStars
import os
import asyncio
from dotenv import load_dotenv

load_dotenv()

async def main():
    api_bs = os.getenv("api_bs") # Your Brawl Stars API token
    tag_p1 = os.getenv("tag_p1") # Brawl Stars Player tag (es. #12345678 or 12345678)

    nb = NovaBrawlStars(api_bs) # Initialize the Brawl Stars API client

    async with nb as client:
        player = await client.get_player(tag_p1) # Get a Player object from the API
        club_members = await client.get_club_members(player.club.tag, limit=5) # Get Club Members with pagination
        after = club_members.paging.cursors.after # Get the 'after' cursor for pagination
        refetched_after_member = await client.get_club_members(player.club.tag, after=after, limit=5) # Refetch Club Members using the 'after' cursor
        before = refetched_after_member.paging.cursors.before # Get the 'before' cursor for pagination
        refetched_before_member = await client.get_club_members(player.club.tag, before=before, limit=5) # Refetch Club Members using the 'before' cursor
    
    await nb.close() # Close the HTTP client session

if __name__ == "__main__":
    asyncio.run(main()) # Run the main function

How to get ranking clubs info using pagination

from novabrawlstars.client import NovaBrawlStars
import os
import asyncio
from dotenv import load_dotenv

load_dotenv()

async def main():
    api_bs = os.getenv("api_bs") # Your Brawl Stars API token

    nb = NovaBrawlStars(api_bs) # Initialize the Brawl Stars API client

    async with nb as client:
        ranking_clubs = await client.get_ranking_clubs("global", limit=5) # Get Ranking Clubs with pagination
        after = ranking_clubs.paging.cursors.after # Get the 'after' cursor for pagination
        refetched_after_club = await client.get_ranking_clubs("global", after=after, limit=5) # Refetch Club Members using the 'after' cursor
        before = refetched_after_club.paging.cursors.before # Get the 'before' cursor for pagination
        refetched_before_club = await client.get_ranking_clubs("global", before=before, limit=5) #  Refetch Club Members using the 'before' cursor
    
    await nb.close() # Close the HTTP client session

if __name__ == "__main__":
    asyncio.run(main()) # Run the main function

How to get ranking brawlers info using pagination

from novabrawlstars.client import NovaBrawlStars
import os
import asyncio
from dotenv import load_dotenv

load_dotenv()

async def main():
    api_bs = os.getenv("api_bs") # Your Brawl Stars API token

    nb = NovaBrawlStars(api_bs) # Initialize the Brawl Stars API client

    async with nb as client:
        brawler_id = "16000000" # Example Brawler ID for Shelly
        ranking_brawler = await client.get_ranking_brawler("global", brawlerId=brawler_id, limit=5) # Get Ranking Brawlers with pagination
        after = ranking_brawler.paging.cursors.after # Get the 'after' cursor for pagination
        refetched_after_brawler = await client.get_ranking_brawler("global", brawlerId=brawler_id, after=after, limit=5) # Refetch Ranking Brawlers using the 'after' cursor
        before = refetched_after_brawler.paging.cursors.before # Get the 'before' cursor for pagination
        refetched_before_brawler = await client.get_ranking_brawler("global", brawlerId=brawler_id ,before=before, limit=5) #  Refetch Ranking Brawlers using the 'before' cursor
    
    await nb.close() # Close the HTTP client session

if __name__ == "__main__":
    asyncio.run(main()) # Run the main function

How to get ranking players info using pagination

from novabrawlstars.client import NovaBrawlStars
import os
import asyncio
from dotenv import load_dotenv

load_dotenv()

async def main():
    api_bs = os.getenv("api_bs") # Your Brawl Stars API token

    nb = NovaBrawlStars(api_bs) # Initialize the Brawl Stars API client

    async with nb as client:
        ranking_player = await client.get_ranking_player("global", limit=5) # Get Ranking Players with pagination
        after = ranking_player.paging.cursors.after # Get the 'after' cursor for pagination
        refetched_after_player = await client.get_ranking_player("global", after=after, limit=5) # Refetch Ranking Players using the 'after' cursor
        before = refetched_after_player.paging.cursors.before # Get the 'before' cursor for pagination
        refetched_before_player = await client.get_ranking_player("global", before=before, limit=5) #  Refetch Ranking Players using the 'before' cursor
    
    await nb.close() # Close the HTTP client session

if __name__ == "__main__":
    asyncio.run(main()) # Run the main function

How to get brawlers info using pagination

from novabrawlstars.client import NovaBrawlStars
import os
import asyncio
from dotenv import load_dotenv

load_dotenv()

async def main():
    api_bs = os.getenv("api_bs") # Your Brawl Stars API token

    nb = NovaBrawlStars(api_bs) # Initialize the Brawl Stars API client

    async with nb as client:
        brawlers = await client.get_brawlers(limit=5) # Get brawlers with pagination
        after = brawlers.paging.cursors.after # Get the 'after' cursor for pagination
        refetched_after_brawlers = await client.get_brawlers(limit=5, after=after) # Refetch brawlers using the 'after' cursor
        before = refetched_after_brawlers.paging.cursors.before # Get the 'before' cursor for pagination
        refetched_before_brawlers = await client.get_brawlers(limit=5, before=before) # Refetch brawlers using the 'before' cursor

    await nb.close() # Close the HTTP client session

if __name__ == "__main__":
    asyncio.run(main()) # Run the main function

How to get brawler info using brawlerId

from novabrawlstars.client import NovaBrawlStars
import os
import asyncio
from dotenv import load_dotenv

load_dotenv()

async def main():
    api_bs = os.getenv("api_bs") # Your Brawl Stars API token

    nb = NovaBrawlStars(api_bs) # Initialize the Brawl Stars API client

    async with nb as client:
        brawler_example = "16000000" # Example brawler ID for Shelly
        brawler = await client.get_brawler(brawler_example) # Get brawler information
        print(brawler.name) # Print the brawler's name

    await nb.close() # Close the HTTP client session

if __name__ == "__main__":
    asyncio.run(main()) # Run the main function

Notes

  • Make sure to replace the player tags and API token.
  • Supports both numeric and #-prefixed tags.

Donate Me 💖

If you like this project and want to support its development, you can donate:

Every contribution helps me maintain and improve the library! Thank you for your support! 🙏

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

novabrawlstars-0.1.9.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

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

novabrawlstars-0.1.9-py3-none-any.whl (26.3 kB view details)

Uploaded Python 3

File details

Details for the file novabrawlstars-0.1.9.tar.gz.

File metadata

  • Download URL: novabrawlstars-0.1.9.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for novabrawlstars-0.1.9.tar.gz
Algorithm Hash digest
SHA256 37c7788c83e63a8e7360e7359751b35a36d9dfedeb84200c5e445a2277d62edf
MD5 aa7ff3acd1f29206893d6be12588183e
BLAKE2b-256 67f5c776913551d90f20dd7b64e92d0f6a3c3e488a29e5b83c48abc02bab302e

See more details on using hashes here.

File details

Details for the file novabrawlstars-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: novabrawlstars-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 26.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for novabrawlstars-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 eb7febce3810c343f4a19db697a403d4ec6c0e86fe7b339f989fc31b93a51ed7
MD5 e9b12f3f729de31ebabb02153a46ada4
BLAKE2b-256 8ff720ee6dc8f098ed86d5a87ff33a4a089279d8f59642e651cb07fbc6c9ac7b

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