Python API to retrieve Overwatch Statistics
Python API to retrieve Overwatch statistics Still in early development but accepting suggestions and PRs.
pip install over_stats
Initialize a player profile by providing the player tag and the platform. The platform is optional and it defaults to ‘pc’. Other valid values are ‘xbl’ and ‘psn’
player_data = over_stats.PlayerProfile('Stylosa#21555')
player_data = over_stats.PlayerProfile('acesarramsan', over_stats.PLAT_PSN)
Download and parse the profile’s data. You do not need to call this method because the first method that needs to download the profile data will do so.
Print the entire profile’s data in JSON format. You will notice that the output is organized in a similar fashion as in the source (https://playoverwatch.com/).
import json print (json.dumps(player_data.raw_data, indent=4))
This library does not hardcode the list of heroes, statistics or achievements. Instead you will need to retrieve those available values for the specific type of data you are retrieving. Even though this approach makes this library a bit more complicated to use, it also allows that new values such as new heroes will be handled transparently.
The list of game modes available for this player can be found with:
The fist section on a player’s profile is the comparison section. Using one of the available modes you can retrieve the list of comparison types:
With a mode and a comparison type you can get the list of available heroes:
Providing a mode, comparison_type and comparison_hero you can get the exact stat value:
player_data.comparisons(mode, comparison_type, comparison_hero)
The mode parameter is required but comparison_type and comparison_hero are optionals. If you want to get the comparison data without been too specific you can provide a mode or a mode and a comparison_type.
The second section is the stat section. The list of heroes can be retrieved by providing a mode:
With a hero and a mode you can retrieve the list of available stat categories:
With a mode, hero and category you will be able to retrieve the list of available stats:
player_data.stat_names(mode, hero, category)
To retrieve the exact stat value you will need to provide a mode, hero, category and stat_name:
player_data.stats(mode, hero, category, stat_name)
The mode parameter is required but hero, category and stat_name are optional. You can also provide only a mode, a mode and a hero or a mode, a hero and a category.
The player’s achievements are not divided between competitive and quickplay. In order to get a list of achievement types availeable you can do the following:
With a achievement type and a list name, you can get a list of achievements.
player_data.achievements(achievement_type, over_stats.ACH_EARNED) player_data.achievements(achievement_type, over_stats.ACH_MISSING)
The achievement_type and list_name are optional arguments. You can also skip both or provide only an achievement_type.
You can find examples of how to use these methods in the demo.py file.
The AWS Python library aka Boto3, has a limitation when dealing with DynamoDB items. You cannot insert an object containing a float to DynamoDB. This is a know issue which as existed for a while so in order to get around it there is flag that can be set when creating the PlayerProfile object. If you set this flag, then all floats will be wrapped in a Decimal, which will allow you to insert them to DynamoDB but they will not be able to be dumped to json.
player_data = over_stats.PlayerProfile('acesarramsan', over_stats.PLAT_PSN, True)
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size over_stats-0.4.0-py3-none-any.whl (19.2 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size over_stats-0.4.0.tar.gz (6.7 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for over_stats-0.4.0-py3-none-any.whl