Data models

This section explains data models used in topggpy to represent data received from Top.gg.

Note

All listed models subclass dict and allow retrieving data via attributes and keys (i.e., both response['id'] and response.id are valid).

DataDict

class topgg.types.DataDict(**kwargs: topgg.types.VT)[source]

Bases: dict, MutableMapping[topgg.types.KT, topgg.types.VT]

Base class used to represent received data from the API.

Every data model subclasses this class.

BotData

class topgg.types.BotData(**kwargs: Any)[source]

Bases: topgg.types.DataDict[str, Any]

Model that contains information about a listed bot on top.gg. The data this model contains can be found here.

UserData

class topgg.types.UserData(**kwargs: Any)[source]

Bases: topgg.types.DataDict[str, Any]

Model that contains information about a top.gg user. The data this model contains can be found here.

SocialData

class topgg.types.SocialData(**kwargs: topgg.types.VT)[source]

Bases: topgg.types.DataDict[str, str]

Model that contains social information about a top.gg user.

youtube: str

The YouTube channel ID of the user.

reddit: str

The Reddit username of the user.

twitter: str

The Twitter username of the user.

instagram: str

The Instagram username of the user.

github: str

The GitHub username of the user.

BriefUserData

class topgg.types.BriefUserData(**kwargs: Any)[source]

Bases: topgg.types.DataDict[str, Any]

Model that contains brief information about a Top.gg user.

id: int

The Discord ID of the user.

username: str

The Discord username of the user.

avatar: str

The Discord avatar URL of the user.

BotStatsData

class topgg.types.BotStatsData(**kwargs: Any)[source]

Bases: topgg.types.DataDict[str, Any]

Model that contains information about a listed bot’s guild and shard count.

server_count: Optional[int]

The amount of servers the bot is in.

shards: List[int]

The amount of servers the bot is in per shard.

shard_count: Optional[int]

The amount of shards a bot has.

VoteDataDict

class topgg.types.VoteDataDict(**kwargs: Any)[source]

Bases: topgg.types.DataDict[str, Any]

Base model that represents received information from Top.gg via webhooks.

type: str

Type of the action (upvote or test).

user: int

ID of the voter.

query: topgg.types.DataDict

Query parameters in DataDict.

BotVoteData

class topgg.types.BotVoteData(**kwargs: Any)[source]

Bases: topgg.types.VoteDataDict

Model that contains information about a bot vote.

bot: int

ID of the bot the user voted for.

is_weekend: bool

Boolean value indicating whether the action was done on a weekend.

ServerVoteData

class topgg.types.ServerVoteData(**kwargs: Any)[source]

Bases: topgg.types.VoteDataDict

Model that contains information about a server vote.

guild: int

ID of the guild the user voted for.

WidgetOptions

class topgg.types.WidgetOptions(id: Optional[int] = None, format: Optional[str] = None, type: Optional[str] = None, noavatar: bool = False, colors: Optional[Dict[str, int]] = None, colours: Optional[Dict[str, int]] = None)[source]

Bases: topgg.types.DataDict[str, Any]

Model that represents widget options that are passed to Top.gg widget URL generated via DBLClient.generate_widget().

id: Optional[int]

ID of a bot to generate the widget for. Must resolve to an ID of a listed bot when converted to a string.

colors: Dict[str, int]

A dictionary consisting of a parameter as a key and HEX color (type int) as value. color will be appended to the key in case it doesn’t end with color.

noavatar: bool

Indicates whether to exclude the bot’s avatar from short widgets. Must be of type bool. Defaults to False.

format: str

Format to apply to the widget. Must be either png and svg. Defaults to png.

type: str

Type of a short widget (status, servers, library, upvotes, and owner). For large widget, must be an empty string.