Skip to main content

WarGaming World of Tanks Console API Wrapper

Project description

`WOTConsole <https://bitbucket.org/kamakazikamikaze/wotconsole>`_
=================================================================

Introduction
------------

WOTConsole is a Python module for interacting with the Wargaming's developer
API, specifically for the `World of Tanks - Console
<https://console.wargaming.com>`_ game. It is a tool designed for convenience
and ease-of-use.

|docs|

Why create another API wrapper?
-------------------------------

While Wargaming offers their own API wrapper, and another was built by a
third-party, they respectively do not have the WOTX (World of Tanks Console)
endpoints or do not have sufficient documentation to understand how to fully
utilize their libraries. As such, I took it upon myself to create one that was
thorough and easy to use.

Why not stick with :py:mod:`~.requests`?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

While the ``requests`` library may suffice for
general use, it can be a bit of a pain having to remember what parameters
should be sent and what the URL endpoint is. It's also inconvenient when
trying to code offline. This module has all of this documented and will track
the URLs for you.

`Eww, Python! <https://goo.gl/3rsOt4>`_
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Grow up ;)

What can it do?
---------------

WOTConsole is designed for convenience to the developer. Let's say that you're
needing to search for a tank.

This module intends to address some of these issues and even those that most
developers may not care for. We can rewrite the code as follows:

.. code:: python

>>> from __future__ import print_function
>>> from copy import copy
>>> from wotconsole import tank_info

>>> apikey = 'demo'

# You can specify the platform and language you want.
>>> psinfo = vehicle_info(apikey, tank_id='1', fields=['short_name',
... 'tier', 'type', 'nation'], api_realm='ps4', language='ru')

# Some parameters accept lists of multiple types
>>> xinfo = tank_info(apikey, tank_id=[1, '257'])
>>> print type(psinfo)
<class 'wotconsole.WOTXResponse'>

# The data returned was a dictionary; the WOTXResponse will behave as one
>>> for tank_id, data in psinfo.iteritems():
... print(tank_id, data)
1 {u'tier': 5, u'type': u'mediumTank', u'short_name': u'T-34',
u'nation': u'ussr'}

# You can directly access the data using indices
>>> print(xinfo['1']['short_name'])
T-34
>>> print(xinfo['257']['short_name'])
SU-85

# Should you need to `copy` the data, access it as an attribute
>>> copied = copy(xinfo.data)
>>> print(type(copied))
<type 'dict'>

>>> try:
... vehicle_info(apikey, tank_id='A')

>>> except WOTXResponseError as wat:
# If an error occurs from bad parameters being sent to the API, the
# `Exception` will instead use the error message sent back in the JSON.
... print(wat)
INVALID_TANK_ID

# The JSON becomes part of the `Exception`, allowing for debugging even
# outside of a method's scope.
... print(wat.error['code'])
407
... print(wat.error['field'])
tank_id

# Both `WOTXResponse` and `WOTXResponseError` save the original
# `requests` instance, just in case the developer wishes to review the
# parameters, URL, etc.
... print(type(wat.raw))
<class 'requests.models.Response'>

What improvements will we see?
------------------------------

An up-to-date list of planned features will always be in the
:file:`TODO.rst` file. Currently it contains:

.. include:: TODO.rst

.. |docs| image:: https://readthedocs.org/projects/docs/badge/?version=latest
:alt: Documentation Status
:scale: 100%
:target: https://wotconsole.readthedocs.io/en/latest/?badge=latest

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

wotconsole-0.4.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

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

wotconsole-0.4-py2.py3-none-any.whl (16.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file wotconsole-0.4.tar.gz.

File metadata

  • Download URL: wotconsole-0.4.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for wotconsole-0.4.tar.gz
Algorithm Hash digest
SHA256 2404966dd94e56ffc62478151c3ac0be88cf5e724c4af77e3a241aaa78c923d1
MD5 b0386d0c34b23e4f259f166019cd4bcf
BLAKE2b-256 08ae660f911414a6422540112597513fcba63b3f174f1aa23659199003dccd4e

See more details on using hashes here.

File details

Details for the file wotconsole-0.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for wotconsole-0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 79332ae93ee6e4fa29f1d102dcb0ebe3b8d06136b44da1b921e7b99d234e45e4
MD5 951f218289927777f6d6715edd544f24
BLAKE2b-256 5f149f02eedc1dbf350db68542c92fbe0b87fdd3eb9c1fdc16dd26b0533f9f4c

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