This Flask app is an update to my Wargaming Game Population console application from December 2019. It incorporates the API calls made by that application into a background task managed by the Advanced Python Scheduler which has been integrated with Flask (Flask-APSchedule).
The Wargaming API is queried via the defined background task in order to collect and store their world-wide server populations. This data is stored into and queried from a DB using SQLAlchemy and display using PyGal.
I kicked off this Flask project using the Flask-Starter project I built previously.
The API request is sent to all four current regions: NA, EU, RU, and Asia. While a relatively simple JSON structure, the resulting response for each region that needs to be parsed looks like:
{
"status": "ok",
"data": {
"wotb": [
{
"players_online":9999,
"server":"NA"
}
],
"wot": [
{
"players_online":9999,
"server":"303"
}
],
"wows": [
{
"players_online":9999,
"server":"NA"
}
]
}
}
This application requires an API key which should be stored in the environment with a small number of other values. The necessary key can be generated on the Wargaming developer portal.