Skip to main content

Python API to retrieve Overwatch Statistics

Project description

Python API to retrieve Overwatch statistics Still in early development but accepting suggestions and PRs.

Installation

pip install over_stats

Requirements

Python 3.6

Usage

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')

or

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.

player_data.load_data()

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:

player_data.modes()

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:

player_data.comparison_types(mode)

With a mode and a comparison type you can get the list of available heroes:

player_data.comparison_heroes(mode, comparison_type)

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:

player_data.stat_heroes(mode)

With a hero and a mode you can retrieve the list of available stat categories:

player_data.stat_categories(mode, hero)

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:

player_data.achievement_types()

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.

Boto3 support

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

over_stats-0.4.0.tar.gz (6.7 kB view hashes)

Uploaded source

Built Distribution

over_stats-0.4.0-py3-none-any.whl (19.2 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page