Skip to content

assets

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

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
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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__(type_id)

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
102
103
104
105
106
107
108
109
110
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)

EconomyAsset

Bases: 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
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, client: Client, data: dict):
        """
        Arguments:
            client: The Client to be used when getting information on assets.
            data: The data from the request.
        """
        super().__init__(client=client, 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(client=client, data=data["Creator"])
        elif self.creator_type == CreatorType.group:
            self.creator: AssetPartialGroup = AssetPartialGroup(client=client, data=data["Creator"])

        self.icon_image: BaseAsset = BaseAsset(client=client, 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"]

__init__(client, data)

Parameters:

Name Type Description Default
client Client

The Client to be used when getting information on assets.

required
data dict

The data from the request.

required
Source code in roblox/assets.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
def __init__(self, client: Client, data: dict):
    """
    Arguments:
        client: The Client to be used when getting information on assets.
        data: The data from the request.
    """
    super().__init__(client=client, 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(client=client, data=data["Creator"])
    elif self.creator_type == CreatorType.group:
        self.creator: AssetPartialGroup = AssetPartialGroup(client=client, data=data["Creator"])

    self.icon_image: BaseAsset = BaseAsset(client=client, 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"]