Git Product home page Git Product logo

python-wowapi's Introduction

python-wowapi

Build Status

Python-wowapi is a client library for interacting with the World of Warcraft endpoins of the Blizzard API

Python-wowapi includes support for the following WoW API's:

  • Game data API
  • Character Profile API

To interact with this library, you need to first get a client-id and client secret by registering your application.

For more information about official World of Warcraft API's visit:

API Docs

For examples and all available endpoints, visit the API Documentation

Installing

pip install python-wowapi

WoW Classic API support

According to this Forum post, Blizzard is adding support for some game data API's.

In order to use these endpoints, you need to provide the classic namespace:

api.get_item_class_index('us', 'static-classic-us')

Development & Testing

make devinstall
pytest

Alternatively you can also run the full drone.io pipeline locally or remote

drone exec

To build the docs:

make docinstall
make docs

python-wowapi's People

Contributors

antoine-lemaitre avatar lockwooddev avatar tehmufifnman 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

python-wowapi's Issues

Community API retired - Game Data missing APIs

Hiya lockwooddev!

Do you plan on updating this with the recent drastic changes in Blizzard's API.

Community API has been completely retired.
Game Data API has added several endpoints, for example an Auction House endpoint that is very different than its old Community API endpoint.

Also one thing to note, with the new Auction House API specifically, we need an option to make a head() only request (no content) to the endpoint. The "last modified" date/time of Auction House data is stored there. Currently this package only returns the JSON from the response.

I was tinkering with some of these changes in a branch but I didn't want to waste time if you were also working on some changes!

If you don't plan on continuing this project, please let me know - I would gladly adopt it.

Thanks for all your work on this, I hope this message finds you safe!

Add new Game Data API endpoints

Only a few hours after the 2.1.0 release adding the game data api's, Blizzard added additional endpoints to this API.

https://us.battle.net/forums/en/bnet/topic/20769659813
https://develop.battle.net/documentation/api-reference/world-of-warcraft-game-data-api

We’re pleased to announce an update to the World of Warcraft® Game Data APIs. As previously mentioned on the Blizzard API Developer Forum, we’ve been hard at work adding Mythic Keystone Dungeon information to character profiles (a.k.a. Armory) and exposing this data to community developers via the WoW Game Data APIs.

We’re adding data for the seasonal best run for each dungeon, including the seasonal best within qualifying time and seasonal best by Keystone level. We’re also adding new statically and dynamically namespaced documents that describe Mythic Keystone Profile Seasons and Dungeons, plus other related documents including Mythic Keystone Affixes, Character Specializations, and more!

Allow get_data_resource to accept filters (i.e. locale)

At the moment, get_data_resource accepts only url and region. It would be useful to accept filters as other api calls do to allow for adding things like locale to url's obtained from the game-data API:

race = api.get_playable_race_index('us', 'static-us', locale='en_US')
human = api.get_data_resource(race['races'][0]['key']['href'], 'us', locale='en_US')

Parse JSON into Python Classes

It would be nice if the json was parsed into python class models. This would allow for better navigation of the data especially within IDEs. I know this would take a decent amount of work, but it would definitely make it nicer. I would be willing to put some time into making this happen.

Error when using get_data_resource

This issue seems to happen randomly/intermittently. I can run my script and it will work fine and then wait a minute before running it again and this error is produced. Any clue? I am on the most recently version.

The relevant code is this:

self._wowapi = WowApi(CLIENT_ID, CLIENT_SECRET)
self._auction_header = self._wowapi.get_auctions(self._region_prefix, self._realm_slug, locale='en_US')
data_url = self._auction_header['files'][0]['url']
self._auction_data = self._wowapi.get_data_resource(data_url, self._region_prefix)

Traceback (most recent call last):
File "E:\Dropbox\Projects\TradeSkillMaster\PyBackend\env\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "E:\Dropbox\Projects\TradeSkillMaster\PyBackend\env\lib\site-packages\urllib3\connectionpool.py", line 384, in _make_request
six.raise_from(e, None)
File "", line 2, in raise_from
File "E:\Dropbox\Projects\TradeSkillMaster\PyBackend\env\lib\site-packages\urllib3\connectionpool.py", line 380, in _make_request
httplib_response = conn.getresponse()
File "C:\Users\Muffin\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1321, in getresponse
response.begin()
File "C:\Users\Muffin\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 296, in begin
version, status, reason = self._read_status()
File "C:\Users\Muffin\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 265, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "E:\Dropbox\Projects\TradeSkillMaster\PyBackend\env\lib\site-packages\requests\adapters.py", line 449, in send
timeout=timeout
File "E:\Dropbox\Projects\TradeSkillMaster\PyBackend\env\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "E:\Dropbox\Projects\TradeSkillMaster\PyBackend\env\lib\site-packages\urllib3\util\retry.py", line 367, in increment
raise six.reraise(type(error), error, _stacktrace)
File "E:\Dropbox\Projects\TradeSkillMaster\PyBackend\env\lib\site-packages\urllib3\packages\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "E:\Dropbox\Projects\TradeSkillMaster\PyBackend\env\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "E:\Dropbox\Projects\TradeSkillMaster\PyBackend\env\lib\site-packages\urllib3\connectionpool.py", line 384, in _make_request
six.raise_from(e, None)
File "", line 2, in raise_from
File "E:\Dropbox\Projects\TradeSkillMaster\PyBackend\env\lib\site-packages\urllib3\connectionpool.py", line 380, in _make_request
httplib_response = conn.getresponse()
File "C:\Users\Muffin\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1321, in getresponse
response.begin()
File "C:\Users\Muffin\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 296, in begin
version, status, reason = self._read_status()
File "C:\Users\Muffin\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 265, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "E:\Dropbox\Projects\TradeSkillMaster\PyBackend\env\lib\site-packages\wowapi\api.py", line 74, in _handle_request
response = self._session.get(url, **kwargs)
File "E:\Dropbox\Projects\TradeSkillMaster\PyBackend\env\lib\site-packages\requests\sessions.py", line 546, in get
return self.request('GET', url, **kwargs)
File "E:\Dropbox\Projects\TradeSkillMaster\PyBackend\env\lib\site-packages\requests\sessions.py", line 533, in request

Bug in the `_get_client_credentials` function when getting other-region data.

Hi, I've noticed a small bug.

api.py: _get_client_credentials(self, region):

    def _get_client_credentials(self, region):
        path = '/oauth/token'
        data = {'grant_type': 'client_credentials'}
        auth = HTTPBasicAuth(self._client_id, self._client_secret)

        #url = 'https://{0}.battle.net{1}'.format(region, path)
        url = 'https://eu.battle.net{1}'.format(region, path)

As you can see, I intentionally commented out the "region.battle.net" code and replaced it with "eu.battle.net". Why?

Because:

# Code:
data = api.get_spell("tw", namespace="static-tw", id=195072, locale='zh_TW')
# Result:
# 2021-07-05 15:24:50,980 - wowapi - WARNING - Invalid response - 401 for https://tw.battle.net/oauth/token

Code 401 means "Unauthorized". I am not authorized to login to tw.battle.net.

Changing it to login to your own account's region and THEN querying the other regions is the correct way to use the API. And yes, to query data from another region you do need to provide a region to the wowapi.get_spell() etc APIs.

So the oauth login must be your region. The query must be the target region.

Furthermore, their documentation pages say that the data is segmented into region locks. Non-Chinese accounts can query all regions except China. Chinese accounts can only query Chinese regions (zh_CN):

get wow_token price

Hello, implement get_wowtoken_price. I wrote it in my downloaded api.py, but i think this is crutch.
def get_resource(self, resource, region, type=None, *args, **filters):
resource = resource.format(*args)

    base_url = self.__base_url.format(region)
    if region == 'cn':
        base_url = 'api.blizzard.com.cn'
    if type == 'token':
        base_url +=  '/data'

Use of "filter"

I'm pulling a wow character profile, which works, but 'fields' seems to do nothing to the output as it still returns all fields. I am following the example you provided:

api.get_character_profile('eu', 'khadgar', 'patchwerk', locale='en_GB', fields='guild,mounts')

Invalid response for oauth token

Getting the following error following update to the latest release (4.0.0)

Invalid response - 400 for https://eu.battle.net/oauth/token?grant_type=client_credentials&client_id=REDACTED&client_secret=REDACTED

with:

wow_api_client.get_guild_roster(GAME_REGION, f"profile-{GAME_REGION}", GAME_REALM, GAME_GUILD)

Need docs

I understand I can make docinstall and make docs to view the docs. But I don't feel I should. For one, it seems shady that I have to install something to see how it works. Secondly, I have zero reasons for installing this package as I can't compare it with the normal WoW API. If anyone has the docs, I'd like to view them.

Getting guild members

It doesn't look like there is a method for getting guild members e.g. WowApi.get_guild_members()

I am able to make this request manually, however it would be nice to keep all my calls contained to your module if possible.

If I get some time maybe I can submit a PR if that is faster.

Great module btw!

Thanks for this API, latest Master works, please update package?

Hi, thank you so much for creating this API wrapper, it's really easy to use!

I noticed that 4.0.0 is broken, but the latest master code works (is able to login). Thanks for fixing it!

However it's still outdated at the pypi package and any other distribution places. :)

403 error when trying to access api.get_characters()

Hi, I'm starting to toy around with python-wowapi and testing some stuff. However, I cannot seem to get some endpoints to work. Namely get_characters() (but I would believe others would be affected).

My code:

>>> from wowapi import WowApi
>>> api = WowApi('CLIENT_ID', 'CLIENT_SECRET')
>>> api.get_characters('us')
Fetching access token..
Fetching new token from: https://us.battle.net/oauth/token?grant_type=client_credentials&client_id=CLIENT_ID&client_secret=CLIENT_SECRET
New token ACCESS_TOKEN expires at 2019-10-02 14:59:08.140700 UTC
Requesting resource: https://us.api.blizzard.com/wow/user/characters with parameters: {'access_token': 'ACCESS_TOKEN'}
Invalid response - https://us.api.blizzard.com/wow/user/characters - 403
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/godlike/sandbox/python-wowapi/wowapi/mixins/community.py", line 160, in get_characters
    return self.get_resource('wow/user/characters', region, **filters)
  File "/home/godlike/sandbox/python-wowapi/wowapi/api.py", line 161, in get_resource
    return self._handle_request(url, region, params=filters)
  File "/home/godlike/sandbox/python-wowapi/wowapi/api.py", line 128, in _handle_request
    raise WowApiException(msg)
wowapi.exceptions.WowApiException: Invalid response - https://us.api.blizzard.com/wow/user/characters - 403

However, other endpoints (public ones maybe?) work just fine:

>>> api.get_character_profile('us', 'kel\'thuzad', 'Stilgan')
Requesting resource: https://us.api.blizzard.com/wow/character/kel'thuzad/Stilgan with parameters: {'access_token': 'ACCESS_TOKEN'}
{'lastModified': 1569896706000, 'name': 'Stilgan', 'realm': "Kel'Thuzad", 'battlegroup': 'Vindication', 'class': 8, 'race': 11, 'gender': 0, 'level': 120, 'achievementPoints': 12530, 'thumbnail': 'kelthuzad/116/174610804-avatar.jpg', 'calcClass': 'e', 'faction': 0, 'totalHonorableKills': 268}
>>> 

Am I doing something wrong? I didn't see if there was any caveat in the documentation, but after tweaking the logging a little bit, the library does appear to be following the correct Oauth flow.

Just to double check, I am able to use the API via https://develop.battle.net/documentation/api-reference/world-of-warcraft-community-api using my client_id and client_secret.

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.