PyRoyale is a light wrapper around the official Clash Royale API
This wrapper has a few use cases, and can easily be used for any or all listed!
- Retrieve JSON information from the API
- Convert Clash Royale JSON data to a more usable format (list or pandas dataframe)
- Custom searches for tournaments, clans, players
The only package requirement is 'requests', which can be installed with
pip install requests
Next, download PyRoyale.py, and add the file to your directory. At the top of your working file, import it with
import PyRoyale as rl
A quick implementation is to get information about your account. The JSON data includes many data points, such as level, wins, trophies, etc. The code is:
import pyroyale as rl
mykey = open('/Users/a1425/Documents/mykey.txt','r').read()
# Initialize Class
pyRoyale = rl.PyRoyale(mykey)
# Call desired method
pyRoyale.get_player_info('YYRVLLUV')
# Retrieve class variable, which is in JSON format
json_info = pyRoyale.player_info
print(json_info)
What you'll get is an unorganized block of JSON data. The goal of V2.0 is to easily select desired data keys and convert them to a pandas dataframe.
Fixed class variables that had the same name.