Git Product home page Git Product logo

brawlstars's Introduction

BrawlStars

Introduction

This is a python sync/async wrapper for the brawl stars API. Docs in progress!

Installation

pip install brawlstars for the stable version

pip install git+https://github.com/umbresp/brawlstars for the beta version

Examples

With Synchronous Client

import brawlstars

client = brawlstars.Client(token="your token here", timeout=5)
player = client.get_player(tag="Q8P2ULP")
print(player.name + " (#" + player.tag + ")") # Prints "Dreemurr (#Q8P2ULP)"

With Asynchronous Client

import brawlstars
import asyncio

async def get_stats():
    client = brawlstars.AsyncClient(token="your token here", timeout=5)
    player = await client.get_player(tag="Q8P2ULP")
    print(player.name + " (#" + player.tag + ")") # Prints "Dreemurr (#Q8P2ULP)"

eventLoop = asyncio.get_event_loop()
eventLoop.run_until_complete(get_stats())

brawlstars's People

Contributors

dependabot[bot] avatar umbresp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

brawlstars's Issues

docstrings

Your docstrings say brawlstars.ValueError. However, this is misleading because it's not brawlstars.ValueError, because ValueError is built-in to python. Change brawlstars.ValueError to just ValueError

TypeError

Traceback (most recent call last):
File "C:\Python39\lib\site-packages\brawlstars\client.py", line 66, in get_player
raise HTTPError(resp.status_code)
File "C:\Python39\lib\site-packages\brawlstars\errors.py", line 29, in init
self.error = 'An error occurred. Status: ' + code
TypeError: can only concatenate str (not "int") to str

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\prog\PycharmProjects\untitled3\brawltracker.py", line 4, in
player = client.get_player(tag="Q8P2ULP")
File "C:\Python39\lib\site-packages\brawlstars\client.py", line 72, in get_player
raise Timeout()
brawlstars.errors.Timeout

Process finished with exit code 1.

code must be str?

uh review?

client.py

  • from .errors import * - don't use wildcard imports
  • self.baseUrl = 'http://brawlstars-api.herokuapp.com/api/' - should be self.base_url
  • a blank __del__...?
  • if tag is None: raise MissingArg('tag') - this is really useless, just don't make it an optional params and python handles it for you
  • [ ]
player = Player(datareturn player

i don't see the point of creating another variable here

  • ^^ the 2 above for get_band
  • get_player and get_profile should be aliases
  • create an __str__
  • personally think get_brawlers and get_id is redundant and get_members
  • classes related to the above ^^

async client

  • most stuff from above
  • except Exception: - just do except:
  • do an except for JSONDecodeError as i said in sharpbit's commit comments, it's because of heroku
  • a LOT of unnecessary coroutines that can just be functions

sidenote

am kinda tired atm so this isn't comprehensive, fix all these and ill look at it again

read this SharpBit/brawlstats#1

I don't think invalidarg or httperror for invalid tag is a good idea, a seperate exception should be raised for that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.