Skip to content

instances

roblox.instances

This module contains classes intended to parse and deal with data from Roblox item instance information endpoints.

instance_classes

AssetInstance (ItemInstance)

Represents an instance of a Roblox asset.

Source code in roblox/instances.py
class AssetInstance(ItemInstance):
    """
    Represents an instance of a Roblox asset.
    """

    def __init__(self, client: Client, data: dict):
        self._client: Client = client
        super().__init__(client=self._client, data=data)

        self.asset: BaseAsset = BaseAsset(client=self._client, asset_id=data["id"])

    def __repr__(self):
        return f"<{self.__class__.__name__} id={self.id} name={self.name!r} type={self.type} asset={self.asset}>"

__init__(self, client: Client, data: dict) special

Source code in roblox/instances.py
def __init__(self, client: Client, data: dict):
    self._client: Client = client
    super().__init__(client=self._client, data=data)

    self.asset: BaseAsset = BaseAsset(client=self._client, asset_id=data["id"])

__repr__(self) special

Source code in roblox/instances.py
def __repr__(self):
    return f"<{self.__class__.__name__} id={self.id} name={self.name!r} type={self.type} asset={self.asset}>"

BadgeInstance (ItemInstance)

Represents an instance of a Roblox badge.

Source code in roblox/instances.py
class BadgeInstance(ItemInstance):
    """
    Represents an instance of a Roblox badge.
    """

    def __init__(self, client: Client, data: dict):
        self._client: Client = client
        super().__init__(client=self._client, data=data)

        self.badge: BaseBadge = BaseBadge(client=self._client, badge_id=data["id"])

    def __repr__(self):
        return f"<{self.__class__.__name__} id={self.id} name={self.name!r} type={self.type} badge={self.badge}>"

__init__(self, client: Client, data: dict) special

Source code in roblox/instances.py
def __init__(self, client: Client, data: dict):
    self._client: Client = client
    super().__init__(client=self._client, data=data)

    self.badge: BaseBadge = BaseBadge(client=self._client, badge_id=data["id"])

__repr__(self) special

Source code in roblox/instances.py
def __repr__(self):
    return f"<{self.__class__.__name__} id={self.id} name={self.name!r} type={self.type} badge={self.badge}>"

GamePassInstance (ItemInstance)

Represents an instance of a Roblox gamepass.

Source code in roblox/instances.py
class GamePassInstance(ItemInstance):
    """
    Represents an instance of a Roblox gamepass.
    """

    def __init__(self, client: Client, data: dict):
        self._client: Client = client
        super().__init__(client=self._client, data=data)

        self.gamepass: BaseGamePass = BaseGamePass(client=self._client, gamepass_id=data["id"])

    def __repr__(self):
        return f"<{self.__class__.__name__} id={self.id} name={self.name!r} type={self.type} gamepass={self.gamepass}>"

__init__(self, client: Client, data: dict) special

Source code in roblox/instances.py
def __init__(self, client: Client, data: dict):
    self._client: Client = client
    super().__init__(client=self._client, data=data)

    self.gamepass: BaseGamePass = BaseGamePass(client=self._client, gamepass_id=data["id"])

__repr__(self) special

Source code in roblox/instances.py
def __repr__(self):
    return f"<{self.__class__.__name__} id={self.id} name={self.name!r} type={self.type} gamepass={self.gamepass}>"

InstanceType (Enum)

Represents an asset instance type.

Source code in roblox/instances.py
class InstanceType(Enum):
    """
    Represents an asset instance type.
    """
    asset = "Asset"
    gamepass = "GamePass"
    badge = "Badge"

asset

badge

gamepass

ItemInstance (BaseInstance)

Represents an instance of a Roblox item of some kind.

Attributes:

Name Type Description
_client Client

The Client object, which is passed to all objects this Client generates.

Source code in roblox/instances.py
class ItemInstance(BaseInstance):
    """
    Represents an instance of a Roblox item of some kind.

    Attributes:
        _client: The Client object, which is passed to all objects this Client generates.
    """

    def __init__(self, client: Client, data: dict):
        """
        Arguments:
            client: The Client.
            data: The data from the endpoint.
        """
        self._client: Client = client

        self.name: str = data["name"]
        self.type: str = data["type"]  # fixme

        super().__init__(client=self._client, instance_id=data["instanceId"])

    def __repr__(self):
        return f"<{self.__class__.__name__} id={self.id} name={self.name!r} type={self.type}>"

__init__(self, client: Client, data: dict) special

Parameters:

Name Type Description Default
client Client

The Client.

required
data dict

The data from the endpoint.

required
Source code in roblox/instances.py
def __init__(self, client: Client, data: dict):
    """
    Arguments:
        client: The Client.
        data: The data from the endpoint.
    """
    self._client: Client = client

    self.name: str = data["name"]
    self.type: str = data["type"]  # fixme

    super().__init__(client=self._client, instance_id=data["instanceId"])

__repr__(self) special

Source code in roblox/instances.py
def __repr__(self):
    return f"<{self.__class__.__name__} id={self.id} name={self.name!r} type={self.type}>"