Skip to content

nariman/wglib

Repository files navigation

Wargaming API Python 3 Library

Wargaming API Library with asyncio support Compatible with Python 3.5+

Build Status Coverage Status Updates Python 3

It's important

Library was created for my personal purposes, so it may contain some bugs and strange code :)

Installation

¯\_(ツ)_/¯ Only manual

Getting started

Creating an API

>>> from wglib import api

>>> wot  = api.WoT("application_id", "region")  # World of Tanks API
>>> wotb = api.WoTB("application_id", "region")  # World of Tanks Blitz API
>>> wotx = api.WoTX("application_id", "platform")  # World of Tanks Console API
>>> wows = api.WoWS("application_id", "region")  # World of Warships API
>>> wowp = api.WoWS("application_id", "region")  # World of Warplanes API
>>> wgn  = api.WGN("application_id", "region")  # Wargaming Network API

Available regions can be found in the Wargaming PAPI documentation. Available platforms at the moment are xbox and ps4.

You can also specify a default language for API:

>>> wot = api.WoT("demo", "ru", language="en")  # World of Tanks API

And use async API:

>>> from wglib.aio import api

>>> aiowgn = api.WGN("application_id", "region")  # Wargaming Network API

Creating a request

Available request methods can be found in the Wargaming PAPI reference.

"""
Game servers info
https://developers.wargaming.net/reference/all/wgn/servers/info/
"""

>>> res = wgn.servers.info(game="wot")
<wglib.api.base.Response object>

>>> res = await aiowgn.servers.info(game="wot")  # async/await syntax
<wglib.api.base.Response object>

Response object contains raw (json) data in the res.raw and parsed data in the res.data.

>>> res.data
{'status': 'ok', 'data': {'wot': [{'server': 'RU1', 'players_online': 47845} ...

>>> res.data["status"]
'ok'
>>> res["status"]  # dict-like
'ok'

License

The MIT License (MIT)

Copyright (c) 2016 Nariman Safiulin

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.