Skip to content

assets

roblox.assets

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

asset_type_names

AssetType

Represents a Roblox asset type.

Attributes:

Name Type Description
id int

Id of the Asset

name Optional[str]

Name of the Asset

Source code in roblox/assets.py
class AssetType:
    """
    Represents a Roblox asset type.

    Attributes:
        id: Id of the Asset
        name: Name of the Asset
    """

    def __init__(self, type_id: int):
        """
        Arguments:
            type_id: The AssetTypeID to instantiate this AssetType object with.
                     This is used to determine the name of the AssetType.
        """

        self.id: int = type_id
        self.name: Optional[str] = asset_type_names.get(type_id)

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

__init__(self, type_id: int) special

Parameters:

Name Type Description Default
type_id int

The AssetTypeID to instantiate this AssetType object with. This is used to determine the name of the AssetType.

required
Source code in roblox/assets.py
def __init__(self, type_id: int):
    """
    Arguments:
        type_id: The AssetTypeID to instantiate this AssetType object with.
                 This is used to determine the name of the AssetType.
    """

    self.id: int = type_id
    self.name: Optional[str] = asset_type_names.get(type_id)

__repr__(self) special

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

EconomyAsset (BaseAsset)

Represents a Roblox asset. It is intended to parse data from https://economy.roblox.com/v2/assets/ASSETID/details.

Attributes:

Name Type Description
id int

Id of the Asset

product_id int

Product id of the asset

name str

Name of the Asset

description str

Description of the Asset

type AssetType

Type of the Asset

creator_type CreatorType

Type of creator can be user or group see enum

creator Union[PartialUser, AssetPartialGroup]

creator can be a user or group object

icon_image BaseAsset

BaseAsset

created datetime

When the asset was created

updated datetime

When the asset was updated for the las time

price Optional[int]

price of the asset

sales int

amount of sales of the asset

is_new bool

if the asset it new

is_for_sale bool

if the asset is for sale

is_public_domain bool

if the asset is public domain

is_limited bool

if the asset is a limited item

is_limited_unique bool

if the asset is a unique limited item

remaining Optional[int]

How many items there are remaining if it is limited

minimum_membership_level int

Minimum membership level required to buy item

content_rating_type_id int

Unknown

sale_availability_locations

Unknown

Source code in roblox/assets.py
class EconomyAsset(BaseAsset):
    """
    Represents a Roblox asset.
    It is intended to parse data from https://economy.roblox.com/v2/assets/ASSETID/details.

    Attributes:
        id: Id of the Asset
        product_id: Product id of the asset
        name: Name of the Asset
        description: Description of the Asset
        type: Type of the Asset
        creator_type: Type of creator can be user or group see enum
        creator: creator can be a user or group object
        icon_image: BaseAsset
        created: When the asset was created
        updated:  When the asset was updated for the las time
        price: price of the asset
        sales: amount of sales of the asset
        is_new: if the asset it new
        is_for_sale: if the asset is for sale
        is_public_domain: if the asset is public domain
        is_limited: if the asset is a limited item
        is_limited_unique: if the asset is a unique limited item
        remaining: How many items there are remaining if it is limited
        minimum_membership_level: Minimum membership level required to buy item
        content_rating_type_id: Unknown
        sale_availability_locations: Unknown
    """

    def __init__(self, shared: ClientSharedObject, data: dict):
        """
        Arguments:
            shared: The ClientSharedObject to be used when getting information on assets.
            data: The data from the request.
        """
        super().__init__(shared=shared, asset_id=data["AssetId"])

        self.product_type: Optional[str] = data["ProductType"]
        self.id: int = data["AssetId"]
        self.product_id: int = data["ProductId"]  # TODO: make this a BaseProduct
        self.name: str = data["Name"]
        self.description: str = data["Description"]
        self.type: AssetType = AssetType(type_id=data["AssetTypeId"])

        self.creator_type: CreatorType = CreatorType(data["Creator"]["CreatorType"])
        self.creator: Union[PartialUser, AssetPartialGroup]

        if self.creator_type == CreatorType.user:
            self.creator: PartialUser = PartialUser(shared=shared, data=data["Creator"])
        elif self.creator_type == CreatorType.group:
            self.creator: AssetPartialGroup = AssetPartialGroup(shared=shared, data=data["Creator"])

        self.icon_image: BaseAsset = BaseAsset(shared=shared, asset_id=data["IconImageAssetId"])

        self.created: datetime = parse(data["Created"])
        self.updated: datetime = parse(data["Updated"])

        self.price: Optional[int] = data["PriceInRobux"]
        self.sales: int = data["Sales"]

        self.is_new: bool = data["IsNew"]
        self.is_for_sale: bool = data["IsForSale"]
        self.is_public_domain: bool = data["IsPublicDomain"]
        self.is_limited: bool = data["IsLimited"]
        self.is_limited_unique: bool = data["IsLimitedUnique"]

        self.remaining: Optional[int] = data["Remaining"]

        self.minimum_membership_level: int = data["MinimumMembershipLevel"]
        self.content_rating_type_id: int = data["ContentRatingTypeId"]
        self.sale_availability_locations = data["SaleAvailabilityLocations"]

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

__init__(self, shared: ClientSharedObject, data: dict) special

Parameters:

Name Type Description Default
shared ClientSharedObject

The ClientSharedObject to be used when getting information on assets.

required
data dict

The data from the request.

required
Source code in roblox/assets.py
def __init__(self, shared: ClientSharedObject, data: dict):
    """
    Arguments:
        shared: The ClientSharedObject to be used when getting information on assets.
        data: The data from the request.
    """
    super().__init__(shared=shared, asset_id=data["AssetId"])

    self.product_type: Optional[str] = data["ProductType"]
    self.id: int = data["AssetId"]
    self.product_id: int = data["ProductId"]  # TODO: make this a BaseProduct
    self.name: str = data["Name"]
    self.description: str = data["Description"]
    self.type: AssetType = AssetType(type_id=data["AssetTypeId"])

    self.creator_type: CreatorType = CreatorType(data["Creator"]["CreatorType"])
    self.creator: Union[PartialUser, AssetPartialGroup]

    if self.creator_type == CreatorType.user:
        self.creator: PartialUser = PartialUser(shared=shared, data=data["Creator"])
    elif self.creator_type == CreatorType.group:
        self.creator: AssetPartialGroup = AssetPartialGroup(shared=shared, data=data["Creator"])

    self.icon_image: BaseAsset = BaseAsset(shared=shared, asset_id=data["IconImageAssetId"])

    self.created: datetime = parse(data["Created"])
    self.updated: datetime = parse(data["Updated"])

    self.price: Optional[int] = data["PriceInRobux"]
    self.sales: int = data["Sales"]

    self.is_new: bool = data["IsNew"]
    self.is_for_sale: bool = data["IsForSale"]
    self.is_public_domain: bool = data["IsPublicDomain"]
    self.is_limited: bool = data["IsLimited"]
    self.is_limited_unique: bool = data["IsLimitedUnique"]

    self.remaining: Optional[int] = data["Remaining"]

    self.minimum_membership_level: int = data["MinimumMembershipLevel"]
    self.content_rating_type_id: int = data["ContentRatingTypeId"]
    self.sale_availability_locations = data["SaleAvailabilityLocations"]

__repr__(self) special

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