Types

The information about all types of library are described here.

Game object types

class toapi.GameObject(id: int, image: str, name: str, grade: int, properties: List[str] | None, score_earned: int, time_played: timedelta)

The dataclass for the objects from Tanki Online

grade

The level of the object (Mk-N, where N is the level). If the object doesn’t have such a property (that’s, our object is a drone or paint), then it’s equal to -1

Type:

int

id

The ID of the game’s object

Type:

int

image

The URL to the image of this object. The image is .tnk file, but it’s possible to render as .png

Type:

str

name

The name of the object

Type:

str

properties

The list with properties of this object. In most cases it’s None

Type:

Optional[List[str]]

score_earned

The count of experience points that were earned when the player played with this object

Type:

int

time_played

The time in the game that was spent with these objects

Type:

timedelta

classmethod from_json(data: Mapping[str, Any]) GameObject

GameObject: Converts JSON data to GameObject

Parameters:

data (Mapping[str, Any]) – The JSON data

static from_list(list: List[Mapping[str, Any]]) List[GameObject]

List[GameObject]: Converts list to list with game’s object

Parameters:

list (List[Mapping[str, Any]]) – The list with Mappingionaries

class toapi.SuppliesObject(id: int, image: str, name: str, usages: int)

The dataclass for the supplies objects from Tanki Online

id

The ID of the game’s object

Type:

int

image

The URL to the image of this object. The image is .tnk file, but it’s possible to render as .png

Type:

str

name

The name of the object

Type:

str

usages

The count of these supplies usages

Type:

int

classmethod from_json(data: Mapping[str, Any]) SuppliesObject

SuppliesObject: Converts JSON data to SuppliesObject

Parameters:

data (Mapping[str, Any]) – The JSON data

static from_list(list: List[Mapping[str, Any]]) List[SuppliesObject]

List[SuppliesObject]: Converts list to list with supplies

Parameters:

list (List[Mapping[str, Any]]) – The list with dicionaries

Mode type

class toapi.Mode(name: str, score_earned: int, time_played: timedelta, type: str)

The dataclass for the game modes

name

The name of the mode

Type:

str

score_earned

The count of experience points that were earned when the player played in this mode

Type:

int

time_played

The time in the game that was spent in this mode

Type:

timedelta

type

The short name of the mode

Type:

str

classmethod from_json(data: Mapping[str, Any]) Mode

Mode: Converts JSON data to Mode

Parameters:

data (Mapping[str, Any]) – The JSON data

static from_list(list: List[Mapping[str, Any]]) List[Mode]

List[Mode]: Converts list to list with game’s object

Parameters:

list (List[Mapping[str, Any]]) – The list with dicionaries

Rank type

class toapi.Rank(number: int)

The dataclass of user rank

number

The player’s rank as number. Has the value from 1 to 31+N, where N is legend_number

Type:

int

property legend_number: int

If the player has the Legend rank, then returns the number of this rank, otherwise returns -1

Type:

int

property name: str

The name of player’s rank

Type:

str

Rating types

class toapi.Rating(position: int, value: int)

The dataclass for the rating

position

The position of the player in any top

Type:

int

value

The value of characteristic of the player, according to which the top was compiled

Type:

int

class toapi.Ratings(crystals: Rating | None, efficiency: Rating | None, golds: Rating | None, score: Rating | None)

The dataclass for the player’s ratings

crystals

The rating by the count of crystals

Type:

Optional[Rating]

efficiency

The rating by the player’s efficiency

Type:

Optional[Rating]

golds

The rating by the count of caught golds

Type:

Optional[Rating]

score

The rating by the score

Type:

Optional[Rating]

classmethod from_json(data: Mapping[str, Any]) Ratings

Ratings: Converts JSON to Ratings

Parameters:

data (Mapping[str, Any]) – The original data of ratings

Status types

class toapi.StableServerStatus(apk_link: str | None, supported_android: Tuple[int, ...], nodes: List[ServerNode])

The dataclass for stable Tanki Online 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%

The link (URL) for download APK of this game

Type:

Optional[str]

supported_android

The tuple with min and max supported Android versions

Type:

Tuple[int, …]

nodes

The list with nodes of the server

Type:

List[ServerNode]

classmethod from_json(data: Mapping[str, Any]) StableServerStatus

StableServerStatus: Converts JSON data to StableServerStatus

Parameters:

data (Mapping[str, Any]) – The JSON data

class toapi.TestServerStatus(release: str, domain: str, user_count: int, nodes: List[ServerNode])

The dataclass for test Tanki Online server

release

The name of this test server

Type:

str

domain

The domain of test server

Type:

str

user_count

The count of the users at test server

Type:

str

nodes

The array with nodes of the server

Type:

List[ServerNode]

property html_url: str

The url to HTML5 version of test server

Type:

str

property flash_url: str

The url to Flash version of test server

Type:

str

classmethod from_json(data: Mapping[str, Any], nodes: Mapping[str, Mapping[str, Any]]) TestServerStatus

TestServerStatus: Converts JSON data to TestServerStatus

Parameters:
  • data (Mapping[str, Any]) – The JSON data

  • nodes (Mapping[str, Mapping[str, Any]]) – The array with nodes of test server

class toapi.ServerNode(name: str, host: str, status: str, tcp_ports: Tuple[int, ...], ws_ports: Tuple[int, ...], inbattles: int, online: int, partners: Mapping[str, Any])

The dataclass for nodes of Tanki Online servers

name

The name of the node

Type:

str

host

The hostname of the node

Type:

str

status

The status of the node

Type:

str

tcp_ports

The tuple with all TCP ports of the node

Type:

Tuple[int, …]

ws_ports

The tuple with all WebSocket ports of the node

Type:

Tuple[int, …]

inbattles

The count of player which in a battle now

Type:

int

online

The count of player which online now

Type:

int

partners

I don’t know what is…. Sorry

Type:

Mapping[str, Any]

classmethod from_json(data: Mapping[str, Any], *, name: str) ServerNode

ServerNode: Converts JSON data to ServerNode

Parameters:
  • data (Mapping[str, Any]) – The JSON data

  • name (str) – The name of the node

Top types

class toapi.Top(name: str, users: List[TopListUser])

The dataclass for the toplists

name

The name of the top

Type:

str

users

The list with users in a top

Type:

List[TopListUser]

classmethod from_json(name: str, value: Sequence[Mapping[str, Any]]) Top

Top: Converts JSON data to Top

Parameters:
  • name (str) – The name of players toplist. In the response from API, it’s key

  • value (Sequence[Mapping[str, Any]]) – The value of players toplist. In the response from API, it’s value

class toapi.TopLists(crystals: Top, efficiency: Top, golds: Top, score: Top)

The dataclass of object with the toplists

crystals

The top-list of players by count of earned crystals

Type:

Top

efficiency

The top-list of players by efficiency

Type:

Top

golds

The top-list of players by count of caught golds

Type:

Top

score

The top-list of players by score

Type:

Top

classmethod from_json(data: Mapping[str, Any]) TopLists

Top: Converts JSON data to Top

Parameters:

data (Mapping[str, Any]) – The JSON data

User types

class toapi.PartialUser(name: str, rank: Rank, premium: bool)

The dataclass of partial (doesn’t contain all information) user

name

The username (login) of the player

Type:

str

rank

The current rank of the player

Type:

Rank

premium

Whether this player has a premium

Type:

bool

class toapi.TopListUser(name: str, rank: Rank, premium: bool, top: str, top_value: int)

The dataclass of user from a top

name

The username (login) of the player

Type:

str

rank

The current rank of the player

Type:

Rank

premium

Whether this player has a premium

Type:

bool

top

The name of the top which this player from

Type:

str

top_value

The value of the characteristic of this player, according to which the top was compiled

Type:

int

classmethod from_json(data: Mapping[str, Any], *, top: str) TopListUser

TopListUser: Converts JSON data to TopListUser

Parameters:
  • data (Mapping[str, Any]) – The JSON data

  • top (str) – The name of the top which this player from

class toapi.User(name: str, rank: Rank, premium: bool, kills: int, deaths: int, caught_golds: int, drones_played: List[GameObject], crystals: int, gear_score: int, hulls_played: List[GameObject], modes_played: List[Mode], mounted: Mapping[str, str], paints_played: List[GameObject], presents: List[Any], previous_rating: Ratings, rating: Ratings, resistance_modules: List[GameObject], score: int, score_base: int, score_next: int, supplies_usage: List[SuppliesObject], turrets_played: List[GameObject])

The dataclass of user from a top

name

The username (login) of the player

Type:

str

rank

The current rank of the player

Type:

Rank

premium

Whether this player has a premium

Type:

bool

kills

The count of player’s kills

Type:

int

deaths

The count of player’s deaths

Type:

int

caught_golds

The count of golds which caught by this player

Type:

int

drones_played

The list with drones which the player is played on

Type:

List[GameObject]

crystals

The count of crystals which this player earned

Type:

int

gear_score

The gear score of this player

Type:

int

hulls_played

The list of hulls which the player is played on

Type:

List[GameObject]

modes_played

The list of modes which the player is played at

Type:

List[Mode]

mounted

Mappingionary where key is a single value from armor, paint and weapon, and value is an image URL with .tnk extension (renamed .png)

Type:

Mapping[str, str]

paints_played

The list of paints which the player is played on

Type:

List[GameObject]

presents

Sorry, I don’t know what is storage by this key

Type:

List[Any]

previous_rating

The rating which the player had early

Type:

Ratings

rating

The rating which the player has currently

Type:

Ratings

resistance_modules

The list of resistance modules which the player is played on

Type:

List[GameObject]

score

This player’s current score points

Type:

int

score_base

The score points that were needed in order to get the current player rank

Type:

int

score_next

Score points that are needed in order to get the next rank

Type:

int

supplies_usage

A list with supplies and the amount of their use by this player

Type:

List[SuppliesObject]

turrets_played

The list of turrets which the player is played on

Type:

List[GameObject]

property kd_ratio: float

Kill/death ratio of this player. The bigger, the better

Type:

float

classmethod from_json(data: Mapping[str, Any]) User

User: Converts JSON data to User

Parameters:

data (Mapping[str, Any]) – The JSON data