Skip to content

Commit e21bcf3

Browse files
authored
Merge pull request #6 from lockwooddev/feature/#5
#5 - Add Game Data API's
2 parents 651a9d1 + a5e82cf commit e21bcf3

File tree

11 files changed

+496
-183
lines changed

11 files changed

+496
-183
lines changed

CHANGELOG.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
# Changelog
22

3-
## 2.0.0
3+
## 2.0.0 (14-10-2018)
44

55
* Deprecate 1.0 WowApi
66
* Implement client credentials flow for OAuth authentication
77
* Add dronefile for testing against multiple python versions
88
* Add coverage to pytest
9-
* Add logging
9+
* Add logging
10+
11+
## 2.0.1 (Unreleased)
12+
13+
* Add drone cloud support for CI
14+
* Bump requests library to 2.20.1
15+
* Change packaging with setup.py
16+
17+
## 2.1.0 (TBD)
18+
19+
* Add Game Data API methods
20+
* Token handling per region

MANIFEST.in

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ include LICENSE.txt
77
include Makefile
88
include pytest.ini
99
recursive-include docs *
10-
recursive-exclude docs/_build *
11-
recursive-exclude * *.pyc
12-
recursive-exclude * *.pyo
13-
recursive-exclude * *.DS_Store
10+
recursive-exclude * *.py[co]
11+
recursive-exclude * *.DS_Store
12+
recursive-exclude * __pycache__

Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: tests devinstall docs clean build test_publish publish
1+
.PHONY: tests devinstall docs clean clean_build build test_publish publish
22

33

44
tests:
@@ -15,6 +15,8 @@ docs: clean
1515
$(MAKE) -C docs html
1616

1717
build:
18+
rm -rf dist
19+
rm -rf build
1820
python setup.py sdist bdist_wheel
1921

2022
test_publish:

README.md

+47-6
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,72 @@
11
# python-wowapi
22

3+
4+
[![](https://img.shields.io/pypi/v/python-wowapi.svg)]( [![](https://img.shields.io/pypi/pyversions/:python-wowapi.svg)](https://pypi.org/project/python-wowapi/))
5+
[![](https://img.shields.io/pypi/pyversions/python-wowapi.svg)](https://pypi.org/project/python-wowapi/)
36
[![Build Status](https://cloud.drone.io/api/badges/lockwooddev/python-wowapi/status.svg)](https://cloud.drone.io/lockwooddev/python-wowapi)
47

8+
9+
510
Python-wowapi is a client library for interacting with the World of Warcraft
6-
Community API.
11+
Community and Game Data API.
12+
13+
To interact with this library, you need to first get a client-id and client secret by registering [here](https://develop.battle.net/access)
714

8-
Documentation about installing and usage can be found at [python-wowapi.readthedocs.org](https://python-wowapi.readthedocs.org)
15+
For more information about official World of Warcraft API's visit:
16+
[Official API documentation](https://develop.battle.net/documentation)
17+
[Official API Forum](https://us.battle.net/forums/en/bnet/15051532/)
18+
19+
API documentation can be found at [python-wowapi.readthedocs.org](https://python-wowapi.readthedocs.org). Examples and installation instructions are documented here.
920

1021
## Installing
1122

1223
```bash
1324
pip install python-wowapi
1425
```
1526

16-
## Usage
27+
## API instance
1728

1829
```python
1930
import os
2031

2132
from wowapi import WowApi
2233

23-
2434
api = WowApi(os.environ['WOW_CLIENT_ID'], os.environ['WOW_CLIENT_SECRET'])
25-
data = api.get_auctions('eu', 'silvermoon', locale='de_DE')
26-
print(data)
2735
```
2836

37+
## Community API example
38+
39+
```python
40+
api.get_auctions('eu', 'silvermoon', locale='de_DE')
41+
```
42+
43+
44+
## Game Data API examples
45+
46+
47+
### Get token price
48+
```python
49+
api.get_token('eu', namespace='dynamic-eu', locale='de_DE')
50+
```
51+
52+
### Get class specializations and detail specialization resource
53+
```python
54+
data = api.get_playable_specializations('us', namespace='static-us')
55+
56+
spec_id = data['character_specializations'][0]['id']
57+
specialization = api.get_playable_specialization('us', namespace='static-us', spec_id=spec_id)
58+
```
59+
60+
### Get game data resource by url
61+
62+
This example shows how to fetch a game data resource by url.
63+
The `get_data_resource` method will take care of adding your access_token to the url.
64+
65+
```python
66+
api.get_data_resource('https://eu.api.blizzard.com/data/wow/connected-realm/509?namespace=dynamic-eu', region='eu')
67+
```
68+
69+
2970
## Development & Testing
3071

3172
```bash

docs/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
year = datetime.datetime.now().strftime('%Y')
2222
copyright ='{0}, Carlo Smouter'.format(year)
2323

24-
version = '2.0.0'
25-
release = '2.0.0'
24+
version = '2.1.0'
25+
release = '2.1.0'
2626

2727
exclude_patterns = ['_build']
2828

docs/index.rst

+4-73
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,14 @@
11
Python-wowapi
22
=============
33

4-
Python-wowapi is a client library for interacting with the World of Warcraft Community API.
4+
For install instructions and examples visit the:
5+
`github readme <https://github.com/lockwooddev/python-wowapi/blob/master/README.md>`_
56

6-
This library requires a client-id and client secret for the Community API OAuth client credentials flow.
77

8-
For more information visit:
9-
10-
- `Official API documentation <https://develop.battle.net/documentation>`_
11-
- `Official API Forum <https://us.battle.net/forums/en/bnet/15051532/>`_
12-
13-
14-
Usage
15-
-----
16-
17-
::
18-
19-
>>> from wowapi import WowApi
20-
>>> api = WowApi('client-id', 'client-secret')
21-
>>> item = api.get_item('eu', 9999)
22-
23-
{
24-
"id": 9999,
25-
"disenchantingSkillRank": 125,
26-
"description": "",
27-
"name": "Black Mageweave Leggings",
28-
"icon": "inv_pants_09",
29-
...
30-
}
31-
32-
::
33-
34-
>>> item = api.get_item('eu', 9999, locale='de_DE')
35-
36-
{
37-
"id": 9999,
38-
"disenchantingSkillRank": 125,
39-
"description": "",
40-
"name": "Schwarze Magiestoffgamaschen",
41-
"icon": "inv_pants_09",
42-
...
43-
}
44-
45-
46-
Api endpoints
47-
-------------
8+
API
9+
---
4810

4911
.. toctree::
5012
:maxdepth: 3
5113

5214
modules/modules
53-
54-
55-
Installation
56-
------------
57-
58-
Install the package with ``pip`` in your terminal::
59-
60-
pip install python-wowapi
61-
62-
63-
Or install the package directly from Github::
64-
65-
pip install git+https://github.com/lockwooddev/python-wowapi.git
66-
67-
68-
Running tests
69-
-------------
70-
71-
.. code-block:: bash
72-
73-
$ make devinstall
74-
$ make tests
75-
76-
77-
Indices and tables
78-
==================
79-
80-
* :ref:`genindex`
81-
* :ref:`modindex`
82-
* :ref:`search`
83-

examples/main.py renamed to examples/community.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
handler.setFormatter(formatter)
1414
logger.addHandler(handler)
1515

16-
logger.info('WowApi example')
16+
logger.info('Community API Example')
1717

1818
api = WowApi(os.environ['WOW_CLIENT_ID'], os.environ['WOW_CLIENT_SECRET'])
1919
data = api.get_auctions('eu', 'silvermoon', locale='de_DE')

examples/game_data.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import logging
2+
import os
3+
from pprint import pprint
4+
5+
from wowapi import WowApi
6+
7+
8+
logger = logging.getLogger('wowapi')
9+
logger.setLevel(logging.INFO)
10+
handler = logging.StreamHandler()
11+
handler.setLevel(logging.INFO)
12+
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
13+
handler.setFormatter(formatter)
14+
logger.addHandler(handler)
15+
16+
logger.info('Game Data API Example')
17+
18+
# fetch token price for region
19+
api = WowApi(os.environ['WOW_CLIENT_ID'], os.environ['WOW_CLIENT_SECRET'])
20+
data = api.get_token('eu', namespace='dynamic-eu', locale='de_DE')
21+
pprint(data)
22+
23+
# get realm list and request detail href with the get_data_resource method
24+
data = api.get_realms('us', namespace='dynamic-us')
25+
detail_url = data['realms'][0]['key']['href']
26+
detail_data = api.get_data_resource(detail_url, region='us')
27+
pprint(detail_data)
28+
29+
# get playable specializations list and fetch a single specialization with the api
30+
data = api.get_playable_specializations('us', namespace='static-us')
31+
spec_id = data['character_specializations'][0]['id']
32+
specialization = api.get_playable_specialization('us', namespace='static-us', spec_id=spec_id)
33+
pprint(specialization)

setup.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import os
22
import codecs
3-
from setuptools import setup
3+
from setuptools import setup, find_packages
44

55

6-
__version__ = '2.0.0'
6+
__version__ = '2.1.0'
77

88

99
def read(*parts):
@@ -17,7 +17,7 @@ def read(*parts):
1717
]
1818

1919
test_requirements = [
20-
'pytest==3.8.2',
20+
'pytest==4.0.1',
2121
'pytest-flakes==4.0.0',
2222
'pytest-pep8==1.0.6',
2323
'pytest-cov==2.6.0',
@@ -38,13 +38,15 @@ def read(*parts):
3838
author='Carlo Smouter',
3939
author_email='[email protected]',
4040
url='https://github.com/lockwooddev/python-wowapi',
41+
packages=find_packages(exclude=['tests', 'tests.*']),
42+
include_package_data=True,
4143
install_requires=install_requirements,
4244
extras_require={
4345
'tests': test_requirements,
4446
'docs': docs_requirements,
4547
},
4648
license='MIT',
47-
keywords=['warcraft', 'api', 'wow', 'auctionhouse', 'community'],
49+
keywords=['warcraft', 'api', 'wow', 'auctionhouse', 'community', 'game'],
4850
classifiers=[
4951
'Development Status :: 4 - Beta',
5052
'Intended Audience :: Developers',
@@ -57,9 +59,4 @@ def read(*parts):
5759
'Programming Language :: Python :: 3.7',
5860
'Topic :: Internet :: WWW/HTTP',
5961
],
60-
packages=[
61-
'wowapi',
62-
'tests',
63-
'docs',
64-
],
6562
)

0 commit comments

Comments
 (0)