Skip to main content

Unofficial Python library that implements the Wargaming.net API and Lesta Games API functionality

Project description

WgLestaAPI

Unofficial Python library that facilitates working with API Wargaming.net and API Lesta Games functionality via Python.

Downloads Downloads Downloads Supported Versions Version GitHub Repo stars

  

By downloading this library you fully agree with all official documents Lesta Games and Wargaming.net about Lesta Games and Wargaming.net products. The author of the library (Alexander Podstrechnyy) is not responsible for your actions performed with the help of this program code.

[!NOTE] If you like this project please add it to favorite :star:
Thanks for your feedback!

Installing the library

Run the command below at the command line

pip install WgLestaAPI

The main advantages

  • The presence of synchronous and asynchronous methods of working with the API;
  • The ability to use any available methods of the official API through this single library;
  • The ability to run a single *.py program in several different regions;
  • Built-in constants to designate all games and regions for API Wargaming.net and API Lesta Games;
  • One App class with all the necessary library methods.

Quickstart

1. Get an application_id

  1. Choice your API provider: API Wargaming.net or API Lesta Games;
  2. Log in to the official API provider service;
  3. Create a new application by clicking on the button Add application or use the existing;
  4. Copy ID field from webpage;

2. Make your first query to API by using dot notation

To get started, you will need to initialize the applications using the received application ID from the official website of the API provider. You will also need to define the API region and the short name of the game that you want to start working with

Next, you can use two approaches to application development - synchronous and asynchronous.

You can also use two approaches to making API requests. The first is to use dot notation to access the methods section and the method itself directly. The second way is to use the execute method. In both cases, the result of the execution will be the same..

A synchron variant

from WgLestaAPI.Application import App
from WgLestaAPI.Constants import REGION, GAMENAMES
import json

# init your app
wgApp = App(
    application_id = "YOUR_APPLICATION_ID",
    region = REGION.EU,
    game_shortname = GAMENAMES.SHORTNAMES.WOT
)

# make a query
data = wgApp.account.info(account_id=563982544)
# processing the response
print(json.dumps(data, indent=2))

An asynchron variant

from WgLestaAPI.Application import AsyncApp
from WgLestaAPI.Constants import REGION, GAMENAMES
import asyncio
import json

# init your app
wgApp = AsyncApp(
    application_id = "YOUR_APPLICATION_ID",
    region = REGION.EU,
    game_shortname = GAMENAMES.SHORTNAMES.WOT
)

async def getAccount(id: int):
    return await wgApp.account.info(account_id=id)

# make a query
data = asyncio.run(getAccount(563982544))
# processing the response
print(json.dumps(data, indent=2))

3. Make your query to API by using the execute method

A synchron variant

from WgLestaAPI.Application import App
from WgLestaAPI.Constants import REGION, GAMENAMES
import json

# init your app
wgApp = App(
    application_id = "YOUR_APPLICATION_ID",
    region = REGION.EU,
    game_shortname = GAMENAMES.SHORTNAMES.WOT
)

# make a query
data = wgApp.execute("account.info", account_id=563982544)
# processing the response
print(json.dumps(data, indent=2))

An asynchron variant

from WgLestaAPI.Application import AsyncApp
from WgLestaAPI.Constants import REGION, GAMENAMES
import asyncio
import json

# init your app
wgApp = AsyncApp(
    application_id = "YOUR_APPLICATION_ID",
    region = REGION.EU,
    game_shortname = GAMENAMES.SHORTNAMES.WOT
)

async def getAccount(id: int):
    return await wgApp.execute("account.info", account_id=id)

# make a query
data = asyncio.run(getAccount(563982544))
# processing the response
print(json.dumps(data, indent=2))

4. Get URL to login, logout and prolongate actions into your application

You can use the library to generate API links for user authorization in your application. This will allow your application to get an access_token, which can be passed as a parameter inside a request to any available API method

from WgLestaAPI.Application import App
from WgLestaAPI.Constants import REGION, GAMENAMES

# init your app
wgApp = App(
    application_id = "YOUR_APPLICATION_ID",
    region = REGION.EU,
    game_shortname = GAMENAMES.SHORTNAMES.WOT
)

print(wgApp.urlLogin(redirect_uri="https://example.com/your-uri-here")) # url to your hosted web-application
print(wgApp.urlLogout())
print(wgApp.urlProlongate())

In the terminal you will see:

https://api.worldoftanks.eu/wot/auth/login/?application_id=YOUR_APPLICATION_ID&redirect_uri=https://example.com/your-uri-here
https://api.worldoftanks.eu/wot/auth/logout/?application_id=YOUR_APPLICATION_ID
https://api.worldoftanks.eu/wot/auth/prolongate/?application_id=YOUR_APPLICATION_ID

Library functionality

The library implements the basic functions of API Lesta Games and API Wargaming.net. All requests are made through your application, which you previously created on Lesta Games or on Wargaming.net. Some features are listed below:

  • Getting information about the player, his equipment and medals.
  • Obtaining information about the clan.
  • Getting information about vehicles.
  • And other methods.

Copyright Notice

 

This program code is not a product of Lesta Games and was developed according to Lesta Games DPP rules.

This program code is not a product of Wargaming.net and is developed according to WG DPP rules.

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

wglestaapi-1.1.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

wglestaapi-1.1.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file wglestaapi-1.1.0.tar.gz.

File metadata

  • Download URL: wglestaapi-1.1.0.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Windows/11

File hashes

Hashes for wglestaapi-1.1.0.tar.gz
Algorithm Hash digest
SHA256 9d129971c32bd0eda60441e86c9fb30ff3ae72f3ea3f6be303a8b92cba7fde81
MD5 55ca5be35dbe1c5682aeb6cdf85d4cca
BLAKE2b-256 bd55459d4d4baed8b7a1fe4c056b76c5248fa1bb17fd86285ba35441df7095f1

See more details on using hashes here.

File details

Details for the file wglestaapi-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: wglestaapi-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Windows/11

File hashes

Hashes for wglestaapi-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 17906c5f1faf3f569885715e6100d5b6179f47d6adaa4f23e3d3805298d25f35
MD5 77c04cac3633257ee8abcf995686b761
BLAKE2b-256 59af6515ef0b4d4a77bee909001b880962687a09f0cfa8c89a811510669e4686

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page