/pybrawl

Work in progress Brawlstars API wrapper for Python. used in: heyudude/Brawl-Stars-Club-Tools

Primary LanguagePythonGNU Lesser General Public License v3.0LGPL-3.0

pybrawl

Unofficial Swagger definition for the official Brawl Stars API

This Python package is automatically generated by the OpenAPI Generator project:

  • API version: 0.0.3
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen For more information, please visit https://github.com/heyudude/pybrawl

Requirements.

Python 2.7 and 3.4+

Installation & Usage

pip install

If the python package is hosted on a repository, you can install directly using:

pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git)

Then import the package:

import pybrawl

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import pybrawl

Getting Started

Please follow the installation procedure and then run the following:

from __future__ import print_function

import time
import pybrawl
from pybrawl.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://api.brawlstars.com/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = pybrawl.Configuration(
    host = "https://api.brawlstars.com/v1"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure Bearer authorization (JWT): JWT
configuration = pybrawl.Configuration(
    access_token = 'YOUR_BEARER_TOKEN'
)


# Enter a context with an instance of the API client
with pybrawl.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = pybrawl.BattlelogApi(api_client)
    player_tag = 'player_tag_example' # str | Tag of the player's battle log to retrieve. 
limit = 56 # int | Limit the number of items returned in the response. (optional)
after = 56 # int | Return only items that occur after this marker. After marker can be found from the response, inside the 'paging' property. Note that only after or before can be specified for a request, not both.  (optional)
before = 56 # int | Return only items that occur before this marker. Before marker can be found from the response, inside the 'paging' property. Note that only after or before can be specified for a request, not both.  (optional)

    try:
        # Get player's battlelog
        api_response = api_instance.get_battlelog(player_tag, limit=limit, after=after, before=before)
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling BattlelogApi->get_battlelog: %s\n" % e)
    

Documentation for API Endpoints

All URIs are relative to https://api.brawlstars.com/v1

Class Method HTTP request Description
BattlelogApi get_battlelog GET /players/{playerTag}/battlelog Get player's battlelog
ClubsApi get_club GET /clubs/{clubTag} Get club information
ClubsApi get_club_members GET /clubs/{clubTag}/members Get members of a club
ClubsApi get_ranking_brawlers GET /clubs/{countryCode}/brawlers/{brawlerId} Get brawler ranking for a country
ClubsApi get_ranking_clubs GET /clubs/{countryCode}/clubs Get club ranking for a country
ClubsApi get_ranking_players GET /clubs/{countryCode}/players Get player ranking for a country
PlayersApi get_player GET /players/{playerTag} Get player information

Documentation For Models

Documentation For Authorization

JWT

  • Type: Bearer authentication (JWT)

Author

Development links

This project uses SonarQube for static analysis. The results of analysis are at SonarCloud. The code quality and test coverage are a work in progress.

Support

If you need help getting this up and running, feel free to hop on the pybrawl discord.