Git Product home page Git Product logo

pywot's Introduction

PyWOT: World of Tanks API для Python

https://travis-ci.org/mattselph/pywot.svg?branch=master

Это интерфейс World of Tanks API для Python . Чтобы работать с API вы должны авторизоваться на Wargaming.net и получить ID приложения. Все получаемые данные в формате JSON

Установка

На данный момент, PyWOT работает на Python 2.6, 2.7. Пакет легко ставится через pip:

$ pip install pywot

Как это работает

Подключаем API и указываем ID. Всё. Код ниже получит список всех танков в игре :

>>> from pywot.api import API
>>> from pywot.tankopedia import Tankopedia
>>> app = API('your-app-id')
>>> t = Tankopedia(app.app_id)
>>> print t.list_of_vehicles()

Получить подробную информацию о конкретном танке можно через метод vehicle_details . Вот так мы узнаем всё о Квасе:

>>> print t.vehicle_details(tank_id=18689)

Или получим лишь несколько полей:

>>> print t.vehicle_details(
        tank_id=18689,
        fields=['tank_id', 'nation', 'speed_limit', 'engines.module_id'])

Имена полей могут быть получены из API Reference. Поиск можно вести по нескольким объектам, передав ключи в виде списка строк.

>>> print t.vehicle_details(
        tank_id=['18689','33'],
        fields=['tank_id', 'nation', 'speed_limit', 'engines.module_id'])

PyWOT поддерживает несколько языков:

>>> print t.vehicle_details(
        language='ko',
        tank_id=['18689','33'],
        fields=['tank_id', 'nation', 'speed_limit', 'engines.module_id'])

Чтобы увидеть доступную статистику игрока, сначала ищем его через search_players. Если у вас есть точный ник игрока , используйте get_account_id для получения account_id этого игрока. Чтобы получить все достижения игрока с ником " lulz_man " делаем следующее:

>>> from pywot.api import API
>>> from pywot.player import Player
>>> app = API('your-app-id')
>>> p = Player(app.app_id)
>>> print p.player_achievements(account_id=p.get_account_id(nickname='lulz_man'))

License

All of the code contained here is licensed by the Apache 2.0 License.

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.