Giter Site home page Giter Site logo

overwatch-api's Introduction

overwatch-api

Python Overwatch API

Install

Requires Python 3.5 or greater!

pip install overwatch-api

[0.5.0] - 2017-04-21

Changes

  • Now using Async, thanks @Drummersbrother!
  • Moving API provider to OWAPI, thanks @Drummersbrother!

Example Code - Supported calls

A segment from example_test.py, which can provide more info on how to use the API.

Call

get_profile(self, battletag: str, regions=(EUROPE, KOREA, AMERICAS, CHINA, JAPAN, ANY),
           platform=None, _session=None, handle_ratelimit=None, max_tries=None, request_timeout=None)


#Platform defaults to PC if not specified.  
#Session can be passed through for a custom aiohttp.Client.
client.get_profile("Danielfrogs#2552")

Code

import asyncio, aiohttp
from overwatch_api.core import AsyncOWAPI
from overwatch_api.constants import *

client = AsyncOWAPI()
await client.get_profile("Danielfrogs#2552", platform=PC)
await client.get_stats("Danielfrogs#2552", platform=XBOX)
await client.get_achievements("Danielfrogs#2552", platform=PLAYSTATION)
await client.get_hero_stats("Danielfrogs#2552")

Testing (Not working in 0.5 yet!)

    python setup.py test

Deprecated Calls (0.4 and below)

from overwatch_api import *

ow = OverwatchAPI()

ow.get_patch_notes()
ow.get_achievements(PC,AMERICAS,'elyK-1940')
ow.get_platforms(PC,AMERICAS,'elyK-1940')
ow.get_profile(PC,AMERICAS,'elyK-1940')
ow.get_stats_all_heroes(PC,AMERICAS,'elyK-1940',COMP)
ow.get_stats_selected_heroes(PC,AMERICAS,'elyK-1940',COMP,[heroes['MERCY'],heroes['LUCIO']])
ow.get_stats_heroes_used(PC,AMERICAS,'elyK-1940',COMP)

overwatch-api's People

Contributors

anthok avatar battleroid avatar dudeofprosper avatar emadmokhtar avatar t04glovern avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

overwatch-api's Issues

Average Stats always empty

Im trying to get the average stats per 10 minutes, aka the average_stats field in the output, but whatever battletag im using, this is the only field thats always empty (its empty in every region too, not only the one that the player plays in)

All calls error out except get_patch_notes() and get_user_achievements()

Same response for get_stats_all_heroes() and get_stats() etc.:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/username/Sites/overwatch-api/env/lib/python2.7/site-packages/overwatch_api/overwatch_api.py", line 83, in get_stats_all_heroes
    'allHeroes/'
  File "/Users/username/Sites/overwatch-api/env/lib/python2.7/site-packages/overwatch_api/overwatch_api.py", line 129, in _base_request
    self.validate_response(r)
  File "/Users/username/Sites/overwatch-api/env/lib/python2.7/site-packages/overwatch_api/overwatch_api.py", line 94, in validate_response
    raise Exception
Exception

Tests update needed

There are some APIs tested and they are changed.

test results

test_get_patch_notes (overwatch_api.tests.TestPatchNotes) ... ok
test_get_patch_notes_keys (overwatch_api.tests.TestPatchNotes) ... ok
test_get_profile (overwatch_api.tests.TestUserMethods) ... ok
test_get_profile_keys (overwatch_api.tests.TestUserMethods) ... ok
test_get_stats (overwatch_api.tests.TestUserMethods) ... ERROR
test_get_stats_all_heroes (overwatch_api.tests.TestUserMethods) ... ok
test_get_stats_all_heroes_keys (overwatch_api.tests.TestUserMethods) ... FAIL
test_get_stats_amount (overwatch_api.tests.TestUserMethods) ... ERROR
test_get_stats_one_hero (overwatch_api.tests.TestUserMethods) ... ERROR
test_get_stats_one_hero_keys (overwatch_api.tests.TestUserMethods) ... ERROR
test_get_user_achievements (overwatch_api.tests.TestUserMethods) ... ERROR
test_get_user_achievements_keys (overwatch_api.tests.TestUserMethods) ... ERROR

======================================================================
ERROR: test_get_stats (overwatch_api.tests.TestUserMethods)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/Emad/Projects/overwatch-api/overwatch_api/tests.py", line 111, in test_get_stats
    result = self.ow.get_stats(PC, AMERICAS, 'elyK-1940', QUICK)
AttributeError: 'OverwatchAPI' object has no attribute 'get_stats'

======================================================================
ERROR: test_get_stats_amount (overwatch_api.tests.TestUserMethods)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/Emad/Projects/overwatch-api/overwatch_api/tests.py", line 115, in test_get_stats_amount
    result = self.ow.get_stats(PC, AMERICAS, 'elyK-1940', QUICK)
AttributeError: 'OverwatchAPI' object has no attribute 'get_stats'

======================================================================
ERROR: test_get_stats_one_hero (overwatch_api.tests.TestUserMethods)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/Emad/Projects/overwatch-api/overwatch_api/tests.py", line 100, in test_get_stats_one_hero
    result = self.ow.get_stats_one_hero(PC, AMERICAS, 'elyK-1940', QUICK,
AttributeError: 'OverwatchAPI' object has no attribute 'get_stats_one_hero'

======================================================================
ERROR: test_get_stats_one_hero_keys (overwatch_api.tests.TestUserMethods)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/Emad/Projects/overwatch-api/overwatch_api/tests.py", line 105, in test_get_stats_one_hero_keys
    result = self.ow.get_stats_one_hero(PC, AMERICAS, 'elyK-1940', QUICK,
AttributeError: 'OverwatchAPI' object has no attribute 'get_stats_one_hero'

======================================================================
ERROR: test_get_user_achievements (overwatch_api.tests.TestUserMethods)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/Emad/Projects/overwatch-api/overwatch_api/tests.py", line 33, in test_get_user_achievements
    result = self.ow.get_user_achievements(PC, AMERICAS, 'elyK-1940')
AttributeError: 'OverwatchAPI' object has no attribute 'get_user_achievements'

======================================================================
ERROR: test_get_user_achievements_keys (overwatch_api.tests.TestUserMethods)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/Emad/Projects/overwatch-api/overwatch_api/tests.py", line 37, in test_get_user_achievements_keys
    result = self.ow.get_user_achievements(PC, AMERICAS, 'elyK-1940')
AttributeError: 'OverwatchAPI' object has no attribute 'get_user_achievements'

======================================================================
FAIL: test_get_stats_all_heroes_keys (overwatch_api.tests.TestUserMethods)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/Emad/Projects/overwatch-api/overwatch_api/tests.py", line 97, in test_get_stats_all_heroes_keys
    self.assertEqual(set(result.keys()), expected_keys)
AssertionError: Items in the first set but not the second:
'ReconAssists-Average'

----------------------------------------------------------------------
Ran 12 tests in 34.691s

FAILED (failures=1, errors=6)

Key

Hi there! Thanks for the API. It seems we need a key to connect now. Will this be available soon?

Mockup tests

Tests are making API request for each test run, we can mockup it and save requests.

We can use VCR.py

Documentation

Hey, I just found your api for overwatch and I'm wondering if there's any documentation for it anywhere? I checked the github wiki and there doesn't seem to be anything there :P

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.