Scripts to query the Clash Royale API
You should be able to just run the script and provide info, as requested. The working directory is important... it's the only file location used, so you have to run the script from the location of your token.txt and clanDonations.xlsx.
The script uses two files:
- token.txt stores your token/key. This file should be one line with the full text of your token. Since its tied to your IP and the API is read-only, leaving it in plain-text is pretty low risk.
- clanDonations.xlsx stores your donation data. The first sheet must be named as the ID of your clan.
- Register or Login: https://developer.clashroyale.com
- Open your accounts page: https://developer.clashroyale.com/#/account
- Create a Key.
- Give it a name and description.
- Use your external IP address (www.whatismyip.com)
- Copy the entire text of your key into the token.txt, or delete token.txt and input the key when your key when prompted.
You'll probably want to get data on a regular basis. Donations are reset for all clan members on Sunday's at 8pm EST (5pm PST).
- Run Task Scheduler
- Right-click 'Task Scheduler Library' > New Folder > Call it ClashRoyale (or whatever)
- Select your new folder and click 'Create Basic Task...' (right-side pane)
- Give it a name.
- Set a desirable time (donations reset at 8pm EST/5pm PST).
- Set the Action to 'Start a Program'.
- Set the program to your python.exe (probably here:
C:\Users\username\AppData\Local\Programs\Python\Python37-32\python.exe) - In 'Add arguments', add the path to your script (in " " if there are any spaces in your path)
- In 'Start in', add the path to the place where want to save your token.txt and workbook. (DO NOT use " " in this path, even if there are spaces.)
- Run this in terminal:
crontab -e - This probably opens the cron config in vim, so push
ito edit. - Move the cursor to a blank line and paste
55 16 * * 0 path/to/your/clanDonations.py - Adjust the time, if needed... the example is set to 4:55pm on Sundays, which
will catch all US time zones. If you're in EST, you could set it to
55 19 * * 0, for example. If you want to collect daily, use55 16 * * * - The token.txt and workbook are created in working directory, which may not be the location of your clanDonations.py.
- Google it. :)