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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file over_stats-0.4.0.tar.gz.

File metadata

  • Download URL: over_stats-0.4.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for over_stats-0.4.0.tar.gz
Algorithm Hash digest
SHA256 e7cb65138772050746e98a15b76ded011ce7cad4809653bfd27db7a0411fc9e8
MD5 a1edb8a433cd1b15da7722ee7e1e3b34
BLAKE2b-256 60887cf6a5dcf2147cca5d99a2c8232e21ff67ed28a96b9f66cbae669cef464e

See more details on using hashes here.

File details

Details for the file over_stats-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: over_stats-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 19.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for over_stats-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1bf68683e093b782218f43246c7e8dcc152db6db008c0db990db161e5cbf4dc2
MD5 78d5b075fea21dd7cdcdd412ac2ddabf
BLAKE2b-256 9e1ace6e4b97719571b7454efd343fa2d26d2a4409f20357d359575b95e3b83e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page