Core API

The basic functions of the library are described here.

get_tops

async toapi.get_tops() TopLists

List[Top]: Gets list with tops of players

Raises:

TankiOnlineException – If the response from the API says that the operation wasn’t successful

Gets and returns the tops of players.

  • Top by count of earned by crystals: TopLists.crystals

  • Top by efficiency: TopLists.efficiency

  • Top by count of caught golds: TopLists.golds

  • Top by score: TopLists.score

Usage
tops: TopLists = await toapi.get_tops()
Example
import asyncio
from toapi import Top, TopLists, get_tops

tops: TopLists = asyncio.run(get_tops())
efficiency_top: Top = tops.efficiency
print("----- Efficiency top -----")
for number, user in enumerate(efficiency_top.users):
    print(f"#{number+1}   {user.name} ({user.top_value})")

Full example located at GitHub.

----- Efficiency top -----
#1   TOP1USERNAME (TOP1VALUE)
#2   TOP2USERNAME (TOP2VALUE)
#3   TOP3USERNAME (TOP3VALUE)
...

get_user

async toapi.get_user(name: str, *, lang: str = 'en') User

User: Tries to find user by the name

Parameters:
  • name (str) – The name of the user

  • lang (str) – The language of API response. By default, en

Raises:

UserNotFoundError – If user with specified :param:`name` isn’t found. This error is possible if a player with such a name doesn’t exist, or he disables the ability to receive information about him through the API

Tries to find user by specified name.

Usage
user: User = await toapi.get_user("USERNAME HERE")

# You can specify the language of API response,
# for doing this use "lang" parameter.
user: User = await toapi.get_user("USERNAME HERE", lang="ru")
Example
import asyncio
from toapi import User, get_user

user: User = asyncio.run(get_user("sty"))
# and You can specify language
# user: User = asyncio.run(get_user("sty", lang="ru"))

print(f"Name: {user.name}")
rank: str = user.rank.name.title()
print(f"Rank: {rank} ({user.score}/{user.score_next} {round(user.score/user.score_next*100)}%)")
print(f"Has premium: {'Yes' if user.premium else 'No'}")
print()
print(f"KD: {user.kills}/{user.deaths} ({user.kd_ratio})")
print(f"Caught golds: {user.caught_golds}")
print(f"Crystals: {user.crystals}")
print(f"GS: {user.gear_score}")

Full example located at GitHub.

Name: sty
Rank: Warrant Officer 1 (57010/76000 75%)
Has premium: No

KD: 611/398 (1.54)
Caught golds: 0
Crystals: 17416
GS: 3238

This data is correct as of May 18, 2023.

get_status

async toapi.get_status() StableServerStatus

StableServerStatus: Gets the status of stable game server.

Maybe deprecated. I don’t know this. Judging by the content of the response from the API, the chance of this is approximately 99%

Gets and returns the status of stable game server.

Warning

Maybe deprecated. I don’t know this. Judging by the content of the response from the API, the chance of this is approximately 99%

Usage
status: StableServerStatus = await toapi.get_status()
Example
import asyncio
from toapi import StableServerStatus, get_status

status: StableServerStatus = asyncio.run(get_status())
print(f"{len(status.nodes)} nodes")
8 nodes

This data is correct as of May 18, 2023.

get_test_status

async toapi.get_test_status() List[TestServerStatus]

List[TestServerStatus]: Gets the status of test game servers

Gets and returns the status of test game servers

Usage
servers: List[TestServerStatus] = await toapi.get_test_status()
Example
import asyncio
from typing import List
from toapi import TestServerStatus, get_test_status

servers: List[TestServerStatus] = asyncio.run(get_test_status())
print(f"Total {len(servers)} test servers\n")
for server in servers:
    print(f"{server.release}: {server.domain}; {server.user_count} users and {len(server.nodes)} nodes")

Full example located at GitHub.

Total 3 test servers

deploy1-pubto: public-deploy1.test-eu.tankionline.com; 73 users and 2 nodes
deploy4-pubto: public-deploy4.test-eu.tankionline.com; 4 users and 2 nodes 
deploy6-pubto: public-deploy6.test-eu.tankionline.com; 1 users and 2 nodes 

This data is correct as of May 18, 2023.