Skip to content

baseuniverse

This file contains the BaseUniverse object, which represents a Roblox universe ID. It also contains the UniverseLiveStats object, which represents a universe's live stats.

BaseUniverse

Bases: BaseItem

Represents a Roblox universe ID.

Attributes:

Name Type Description
id int

The universe ID.

Source code in roblox/bases/baseuniverse.py
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
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
class BaseUniverse(BaseItem):
    """
    Represents a Roblox universe ID.

    Attributes:
        id: The universe ID.
    """

    def __init__(self, client: Client, universe_id: int):
        """
        Arguments:
            client: The Client this object belongs to.
            universe_id: The universe ID.
        """

        self._client: Client = client
        self.id: int = universe_id

    async def get_favorite_count(self) -> int:
        """
        Grabs the universe's favorite count.

        Returns:
            The universe's favorite count.
        """
        favorite_count_response = await self._client.requests.get(
            url=self._client.url_generator.get_url("games", f"v1/games/{self.id}/favorites/count")
        )
        favorite_count_data = favorite_count_response.json()
        return favorite_count_data["favoritesCount"]

    async def is_favorited(self) -> bool:
        """
        Grabs the authenticated user's favorite status for this game.

        Returns:
            Whether the authenticated user has favorited this game.
        """
        is_favorited_response = await self._client.requests.get(
            url=self._client.url_generator.get_url("games", f"v1/games/{self.id}/favorites")
        )
        is_favorited_data = is_favorited_response.json()
        return is_favorited_data["isFavorited"]

    def get_badges(self, page_size: int = 10, sort_order: SortOrder = SortOrder.Ascending,
                   max_items: int = None) -> PageIterator:
        """
        Gets the universe's badges.

        Arguments:
            page_size: How many members should be returned for each page.
            sort_order: Order in which data should be grabbed.
            max_items: The maximum items to return when looping through this object.

        Returns:
            A PageIterator containing this universe's badges.
        """

        return PageIterator(
            client=self._client,
            url=self._client.url_generator.get_url("badges", f"v1/universes/{self.id}/badges"),
            page_size=page_size,
            sort_order=sort_order,
            max_items=max_items,
            handler=_universe_badges_handler,
        )

    async def get_live_stats(self) -> UniverseLiveStats:
        """
        Gets the universe's live stats.
        This data does not update live. These are just the stats that are shown on the website's live stats display.

        Returns:
            The universe's live stats.
        """
        stats_response = await self._client.requests.get(
            url=self._client.url_generator.get_url("develop", f"v1/universes/{self.id}/live-stats")
        )
        stats_data = stats_response.json()
        return UniverseLiveStats(data=stats_data)

    def get_gamepasses(self, page_size: int = 10, sort_order: SortOrder = SortOrder.Ascending,
                       max_items: int = None) -> PageIterator:
        """
        Gets the universe's gamepasses.

        Arguments:
            page_size: How many members should be returned for each page.
            sort_order: Order in which data should be grabbed.
            max_items: The maximum items to return when looping through this object.

        Returns:
            A PageIterator containing the universe's gamepasses.
        """

        return PageIterator(
            client=self._client,
            url=self._client.url_generator.get_url("games", f"v1/games/{self.id}/game-passes"),
            page_size=page_size,
            sort_order=sort_order,
            max_items=max_items,
            handler=lambda client, data: GamePass(client, data),
        )

    async def get_social_links(self) -> List[SocialLink]:
        """
        Gets the universe's social links.

        Returns:
            A list of the universe's social links.
        """

        links_response = await self._client.requests.get(
            url=self._client.url_generator.get_url("games", f"v1/games/{self.id}/social-links/list")
        )
        links_data = links_response.json()["data"]
        return [SocialLink(client=self._client, data=link_data) for link_data in links_data]

__init__(client, universe_id)

Parameters:

Name Type Description Default
client Client

The Client this object belongs to.

required
universe_id int

The universe ID.

required
Source code in roblox/bases/baseuniverse.py
52
53
54
55
56
57
58
59
60
def __init__(self, client: Client, universe_id: int):
    """
    Arguments:
        client: The Client this object belongs to.
        universe_id: The universe ID.
    """

    self._client: Client = client
    self.id: int = universe_id

get_badges(page_size=10, sort_order=SortOrder.Ascending, max_items=None)

Gets the universe's badges.

Parameters:

Name Type Description Default
page_size int

How many members should be returned for each page.

10
sort_order SortOrder

Order in which data should be grabbed.

Ascending
max_items int

The maximum items to return when looping through this object.

None

Returns:

Type Description
PageIterator

A PageIterator containing this universe's badges.

Source code in roblox/bases/baseuniverse.py
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
def get_badges(self, page_size: int = 10, sort_order: SortOrder = SortOrder.Ascending,
               max_items: int = None) -> PageIterator:
    """
    Gets the universe's badges.

    Arguments:
        page_size: How many members should be returned for each page.
        sort_order: Order in which data should be grabbed.
        max_items: The maximum items to return when looping through this object.

    Returns:
        A PageIterator containing this universe's badges.
    """

    return PageIterator(
        client=self._client,
        url=self._client.url_generator.get_url("badges", f"v1/universes/{self.id}/badges"),
        page_size=page_size,
        sort_order=sort_order,
        max_items=max_items,
        handler=_universe_badges_handler,
    )

get_favorite_count() async

Grabs the universe's favorite count.

Returns:

Type Description
int

The universe's favorite count.

Source code in roblox/bases/baseuniverse.py
62
63
64
65
66
67
68
69
70
71
72
73
async def get_favorite_count(self) -> int:
    """
    Grabs the universe's favorite count.

    Returns:
        The universe's favorite count.
    """
    favorite_count_response = await self._client.requests.get(
        url=self._client.url_generator.get_url("games", f"v1/games/{self.id}/favorites/count")
    )
    favorite_count_data = favorite_count_response.json()
    return favorite_count_data["favoritesCount"]

get_gamepasses(page_size=10, sort_order=SortOrder.Ascending, max_items=None)

Gets the universe's gamepasses.

Parameters:

Name Type Description Default
page_size int

How many members should be returned for each page.

10
sort_order SortOrder

Order in which data should be grabbed.

Ascending
max_items int

The maximum items to return when looping through this object.

None

Returns:

Type Description
PageIterator

A PageIterator containing the universe's gamepasses.

Source code in roblox/bases/baseuniverse.py
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
def get_gamepasses(self, page_size: int = 10, sort_order: SortOrder = SortOrder.Ascending,
                   max_items: int = None) -> PageIterator:
    """
    Gets the universe's gamepasses.

    Arguments:
        page_size: How many members should be returned for each page.
        sort_order: Order in which data should be grabbed.
        max_items: The maximum items to return when looping through this object.

    Returns:
        A PageIterator containing the universe's gamepasses.
    """

    return PageIterator(
        client=self._client,
        url=self._client.url_generator.get_url("games", f"v1/games/{self.id}/game-passes"),
        page_size=page_size,
        sort_order=sort_order,
        max_items=max_items,
        handler=lambda client, data: GamePass(client, data),
    )

get_live_stats() async

Gets the universe's live stats. This data does not update live. These are just the stats that are shown on the website's live stats display.

Returns:

Type Description
UniverseLiveStats

The universe's live stats.

Source code in roblox/bases/baseuniverse.py
111
112
113
114
115
116
117
118
119
120
121
122
123
async def get_live_stats(self) -> UniverseLiveStats:
    """
    Gets the universe's live stats.
    This data does not update live. These are just the stats that are shown on the website's live stats display.

    Returns:
        The universe's live stats.
    """
    stats_response = await self._client.requests.get(
        url=self._client.url_generator.get_url("develop", f"v1/universes/{self.id}/live-stats")
    )
    stats_data = stats_response.json()
    return UniverseLiveStats(data=stats_data)

Gets the universe's social links.

Returns:

Type Description
List[SocialLink]

A list of the universe's social links.

Source code in roblox/bases/baseuniverse.py
148
149
150
151
152
153
154
155
156
157
158
159
160
async def get_social_links(self) -> List[SocialLink]:
    """
    Gets the universe's social links.

    Returns:
        A list of the universe's social links.
    """

    links_response = await self._client.requests.get(
        url=self._client.url_generator.get_url("games", f"v1/games/{self.id}/social-links/list")
    )
    links_data = links_response.json()["data"]
    return [SocialLink(client=self._client, data=link_data) for link_data in links_data]

is_favorited() async

Grabs the authenticated user's favorite status for this game.

Returns:

Type Description
bool

Whether the authenticated user has favorited this game.

Source code in roblox/bases/baseuniverse.py
75
76
77
78
79
80
81
82
83
84
85
86
async def is_favorited(self) -> bool:
    """
    Grabs the authenticated user's favorite status for this game.

    Returns:
        Whether the authenticated user has favorited this game.
    """
    is_favorited_response = await self._client.requests.get(
        url=self._client.url_generator.get_url("games", f"v1/games/{self.id}/favorites")
    )
    is_favorited_data = is_favorited_response.json()
    return is_favorited_data["isFavorited"]

UniverseLiveStats

Represents a universe's live stats.

Attributes:

Name Type Description
total_player_count int

The amount of players present in this universe's subplaces.

game_count int

The amount of active servers for this universe's subplaces.

player_counts_by_device_type Dict[str, int]

A dictionary where the keys are device types and the values are the amount of this universe's subplace's active players which are on that device type.

Source code in roblox/bases/baseuniverse.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class UniverseLiveStats:
    """
    Represents a universe's live stats.

    Attributes:
        total_player_count: The amount of players present in this universe's subplaces.
        game_count: The amount of active servers for this universe's subplaces.
        player_counts_by_device_type: A dictionary where the keys are device types and the values are the amount of
                                      this universe's subplace's active players which are on that device type.
    """

    def __init__(self, data: dict):
        self.total_player_count: int = data["totalPlayerCount"]
        self.game_count: int = data["gameCount"]
        self.player_counts_by_device_type: Dict[str, int] = data["playerCountsByDeviceType"]