Skip to content

User Routes

UserRouteInterface

Bases: ClientMixin

Source code in src/bungio/api/bungie/user.py
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 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
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
187
188
189
190
191
192
193
194
195
196
@custom_define()
class UserRouteInterface(ClientMixin):
    async def get_bungie_net_user_by_id(self, id: int, auth: Optional[AuthData] = None) -> GeneralUser:
        """
        Loads a bungienet user by membership id.

        Args:
            id: The requested Bungie.net membership id.
            auth: Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

        Returns:
            The model which is returned by bungie. [General endpoint information.](https://bungie-net.github.io/multi/index.html)
        """

        response = await self._client.http.get_bungie_net_user_by_id(id=id, auth=auth)
        return await GeneralUser.from_dict(data=response, client=self._client, id=id, auth=auth)

    async def get_sanitized_platform_display_names(
        self, membership_id: int, auth: Optional[AuthData] = None
    ) -> dict[BungieCredentialType, str]:
        """
        Gets a list of all display names linked to this membership id but sanitized (profanity filtered). Obeys all visibility rules of calling user and is heavily cached.

        Args:
            membership_id: The requested membership id to load.
            auth: Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

        Returns:
            The model which is returned by bungie. [General endpoint information.](https://bungie-net.github.io/multi/index.html)
        """

        response = await self._client.http.get_sanitized_platform_display_names(membership_id=membership_id, auth=auth)
        return {key: value async for key, value in AllowAsyncIteration(response["Response"].items())}

    async def get_credential_types_for_target_account(
        self, membership_id: int, auth: Optional[AuthData] = None
    ) -> list[GetCredentialTypesForAccountResponse]:
        """
        Returns a list of credential types attached to the requested account

        Args:
            membership_id: The user's membership id
            auth: Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

        Returns:
            The model which is returned by bungie. [General endpoint information.](https://bungie-net.github.io/multi/index.html)
        """

        response = await self._client.http.get_credential_types_for_target_account(
            membership_id=membership_id, auth=auth
        )
        return [
            await GetCredentialTypesForAccountResponse.from_dict(
                data=value, client=self._client, membership_id=membership_id, auth=auth
            )
            for value in response["Response"]
        ]

    async def get_available_themes(self, auth: Optional[AuthData] = None) -> list[UserTheme]:
        """
        Returns a list of all available user themes.

        Args:
            auth: Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

        Returns:
            The model which is returned by bungie. [General endpoint information.](https://bungie-net.github.io/multi/index.html)
        """

        response = await self._client.http.get_available_themes(auth=auth)
        return [await UserTheme.from_dict(data=value, client=self._client, auth=auth) for value in response["Response"]]

    async def get_membership_data_by_id(
        self, membership_id: int, membership_type: Union[BungieMembershipType, int], auth: Optional[AuthData] = None
    ) -> UserMembershipData:
        """
        Returns a list of accounts associated with the supplied membership ID and membership type. This will include all linked accounts (even when hidden) if supplied credentials permit it.

        Args:
            membership_id: The membership ID of the target user.
            membership_type: Type of the supplied membership ID.
            auth: Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

        Returns:
            The model which is returned by bungie. [General endpoint information.](https://bungie-net.github.io/multi/index.html)
        """

        response = await self._client.http.get_membership_data_by_id(
            membership_id=membership_id, membership_type=getattr(membership_type, "value", membership_type), auth=auth
        )
        return await UserMembershipData.from_dict(
            data=response, client=self._client, membership_id=membership_id, membership_type=membership_type, auth=auth
        )

    async def get_membership_data_for_current_user(self, auth: AuthData) -> UserMembershipData:
        """
        Returns a list of accounts associated with signed in user. This is useful for OAuth implementations that do not give you access to the token response.

        Warning: Requires Authentication.
            Required oauth2 scopes: ReadBasicUserProfile

        Args:
            auth: Authentication information.

        Returns:
            The model which is returned by bungie. [General endpoint information.](https://bungie-net.github.io/multi/index.html)
        """

        response = await self._client.http.get_membership_data_for_current_user(auth=auth)
        return await UserMembershipData.from_dict(data=response, client=self._client, auth=auth)

    async def get_membership_from_hard_linked_credential(
        self, credential: str, cr_type: Union[BungieCredentialType, int], auth: Optional[AuthData] = None
    ) -> HardLinkedUserMembership:
        """
        Gets any hard linked membership given a credential. Only works for credentials that are public (just SteamID64 right now). Cross Save aware.

        Args:
            credential: The credential to look up. Must be a valid SteamID64.
            cr_type: The credential type. 'SteamId' is the only valid value at present.
            auth: Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

        Returns:
            The model which is returned by bungie. [General endpoint information.](https://bungie-net.github.io/multi/index.html)
        """

        response = await self._client.http.get_membership_from_hard_linked_credential(
            credential=credential, cr_type=getattr(cr_type, "value", cr_type), auth=auth
        )
        return await HardLinkedUserMembership.from_dict(
            data=response, client=self._client, credential=credential, cr_type=cr_type, auth=auth
        )

    async def search_by_global_name_prefix(
        self, display_name_prefix: str, page: int, auth: Optional[AuthData] = None
    ) -> UserSearchResponse:
        """
        [OBSOLETE] Do not use this to search users, use SearchByGlobalNamePost instead.

        Args:
            display_name_prefix: The display name prefix you're looking for.
            page: The zero-based page of results you desire.
            auth: Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

        Returns:
            The model which is returned by bungie. [General endpoint information.](https://bungie-net.github.io/multi/index.html)
        """

        response = await self._client.http.search_by_global_name_prefix(
            display_name_prefix=display_name_prefix, page=page, auth=auth
        )
        return await UserSearchResponse.from_dict(
            data=response, client=self._client, display_name_prefix=display_name_prefix, page=page, auth=auth
        )

    async def search_by_global_name_post(
        self, data: UserSearchPrefixRequest, page: int, auth: Optional[AuthData] = None
    ) -> UserSearchResponse:
        """
        Given the prefix of a global display name, returns all users who share that name.

        Args:
            data: The required data for this request.
            page: The zero-based page of results you desire.
            auth: Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

        Returns:
            The model which is returned by bungie. [General endpoint information.](https://bungie-net.github.io/multi/index.html)
        """

        response = await self._client.http.search_by_global_name_post(
            page=page, auth=auth, **data.to_dict(_return_to_bungie_case=False)
        )
        return await UserSearchResponse.from_dict(data=response, client=self._client, page=page, auth=auth)

get_available_themes(auth=None) async

Returns a list of all available user themes.

Parameters:

Name Type Description Default
auth Optional[AuthData]

Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

None

Returns:

Type Description
list[UserTheme]

The model which is returned by bungie. General endpoint information.

Source code in src/bungio/api/bungie/user.py
81
82
83
84
85
86
87
88
89
90
91
92
93
async def get_available_themes(self, auth: Optional[AuthData] = None) -> list[UserTheme]:
    """
    Returns a list of all available user themes.

    Args:
        auth: Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

    Returns:
        The model which is returned by bungie. [General endpoint information.](https://bungie-net.github.io/multi/index.html)
    """

    response = await self._client.http.get_available_themes(auth=auth)
    return [await UserTheme.from_dict(data=value, client=self._client, auth=auth) for value in response["Response"]]

get_bungie_net_user_by_id(id, auth=None) async

Loads a bungienet user by membership id.

Parameters:

Name Type Description Default
id int

The requested Bungie.net membership id.

required
auth Optional[AuthData]

Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

None

Returns:

Type Description
GeneralUser

The model which is returned by bungie. General endpoint information.

Source code in src/bungio/api/bungie/user.py
25
26
27
28
29
30
31
32
33
34
35
36
37
38
async def get_bungie_net_user_by_id(self, id: int, auth: Optional[AuthData] = None) -> GeneralUser:
    """
    Loads a bungienet user by membership id.

    Args:
        id: The requested Bungie.net membership id.
        auth: Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

    Returns:
        The model which is returned by bungie. [General endpoint information.](https://bungie-net.github.io/multi/index.html)
    """

    response = await self._client.http.get_bungie_net_user_by_id(id=id, auth=auth)
    return await GeneralUser.from_dict(data=response, client=self._client, id=id, auth=auth)

get_credential_types_for_target_account(membership_id, auth=None) async

Returns a list of credential types attached to the requested account

Parameters:

Name Type Description Default
membership_id int

The user's membership id

required
auth Optional[AuthData]

Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

None

Returns:

Type Description
list[GetCredentialTypesForAccountResponse]

The model which is returned by bungie. General endpoint information.

Source code in src/bungio/api/bungie/user.py
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
async def get_credential_types_for_target_account(
    self, membership_id: int, auth: Optional[AuthData] = None
) -> list[GetCredentialTypesForAccountResponse]:
    """
    Returns a list of credential types attached to the requested account

    Args:
        membership_id: The user's membership id
        auth: Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

    Returns:
        The model which is returned by bungie. [General endpoint information.](https://bungie-net.github.io/multi/index.html)
    """

    response = await self._client.http.get_credential_types_for_target_account(
        membership_id=membership_id, auth=auth
    )
    return [
        await GetCredentialTypesForAccountResponse.from_dict(
            data=value, client=self._client, membership_id=membership_id, auth=auth
        )
        for value in response["Response"]
    ]

get_membership_data_by_id(membership_id, membership_type, auth=None) async

Returns a list of accounts associated with the supplied membership ID and membership type. This will include all linked accounts (even when hidden) if supplied credentials permit it.

Parameters:

Name Type Description Default
membership_id int

The membership ID of the target user.

required
membership_type Union[BungieMembershipType, int]

Type of the supplied membership ID.

required
auth Optional[AuthData]

Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

None

Returns:

Type Description
UserMembershipData

The model which is returned by bungie. General endpoint information.

Source code in src/bungio/api/bungie/user.py
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
async def get_membership_data_by_id(
    self, membership_id: int, membership_type: Union[BungieMembershipType, int], auth: Optional[AuthData] = None
) -> UserMembershipData:
    """
    Returns a list of accounts associated with the supplied membership ID and membership type. This will include all linked accounts (even when hidden) if supplied credentials permit it.

    Args:
        membership_id: The membership ID of the target user.
        membership_type: Type of the supplied membership ID.
        auth: Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

    Returns:
        The model which is returned by bungie. [General endpoint information.](https://bungie-net.github.io/multi/index.html)
    """

    response = await self._client.http.get_membership_data_by_id(
        membership_id=membership_id, membership_type=getattr(membership_type, "value", membership_type), auth=auth
    )
    return await UserMembershipData.from_dict(
        data=response, client=self._client, membership_id=membership_id, membership_type=membership_type, auth=auth
    )

get_membership_data_for_current_user(auth) async

Returns a list of accounts associated with signed in user. This is useful for OAuth implementations that do not give you access to the token response.

Requires Authentication.

Required oauth2 scopes: ReadBasicUserProfile

Parameters:

Name Type Description Default
auth AuthData

Authentication information.

required

Returns:

Type Description
UserMembershipData

The model which is returned by bungie. General endpoint information.

Source code in src/bungio/api/bungie/user.py
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
async def get_membership_data_for_current_user(self, auth: AuthData) -> UserMembershipData:
    """
    Returns a list of accounts associated with signed in user. This is useful for OAuth implementations that do not give you access to the token response.

    Warning: Requires Authentication.
        Required oauth2 scopes: ReadBasicUserProfile

    Args:
        auth: Authentication information.

    Returns:
        The model which is returned by bungie. [General endpoint information.](https://bungie-net.github.io/multi/index.html)
    """

    response = await self._client.http.get_membership_data_for_current_user(auth=auth)
    return await UserMembershipData.from_dict(data=response, client=self._client, auth=auth)

get_membership_from_hard_linked_credential(credential, cr_type, auth=None) async

Gets any hard linked membership given a credential. Only works for credentials that are public (just SteamID64 right now). Cross Save aware.

Parameters:

Name Type Description Default
credential str

The credential to look up. Must be a valid SteamID64.

required
cr_type Union[BungieCredentialType, int]

The credential type. 'SteamId' is the only valid value at present.

required
auth Optional[AuthData]

Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

None

Returns:

Type Description
HardLinkedUserMembership

The model which is returned by bungie. General endpoint information.

Source code in src/bungio/api/bungie/user.py
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
async def get_membership_from_hard_linked_credential(
    self, credential: str, cr_type: Union[BungieCredentialType, int], auth: Optional[AuthData] = None
) -> HardLinkedUserMembership:
    """
    Gets any hard linked membership given a credential. Only works for credentials that are public (just SteamID64 right now). Cross Save aware.

    Args:
        credential: The credential to look up. Must be a valid SteamID64.
        cr_type: The credential type. 'SteamId' is the only valid value at present.
        auth: Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

    Returns:
        The model which is returned by bungie. [General endpoint information.](https://bungie-net.github.io/multi/index.html)
    """

    response = await self._client.http.get_membership_from_hard_linked_credential(
        credential=credential, cr_type=getattr(cr_type, "value", cr_type), auth=auth
    )
    return await HardLinkedUserMembership.from_dict(
        data=response, client=self._client, credential=credential, cr_type=cr_type, auth=auth
    )

get_sanitized_platform_display_names(membership_id, auth=None) async

Gets a list of all display names linked to this membership id but sanitized (profanity filtered). Obeys all visibility rules of calling user and is heavily cached.

Parameters:

Name Type Description Default
membership_id int

The requested membership id to load.

required
auth Optional[AuthData]

Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

None

Returns:

Type Description
dict[BungieCredentialType, str]

The model which is returned by bungie. General endpoint information.

Source code in src/bungio/api/bungie/user.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
async def get_sanitized_platform_display_names(
    self, membership_id: int, auth: Optional[AuthData] = None
) -> dict[BungieCredentialType, str]:
    """
    Gets a list of all display names linked to this membership id but sanitized (profanity filtered). Obeys all visibility rules of calling user and is heavily cached.

    Args:
        membership_id: The requested membership id to load.
        auth: Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

    Returns:
        The model which is returned by bungie. [General endpoint information.](https://bungie-net.github.io/multi/index.html)
    """

    response = await self._client.http.get_sanitized_platform_display_names(membership_id=membership_id, auth=auth)
    return {key: value async for key, value in AllowAsyncIteration(response["Response"].items())}

search_by_global_name_post(data, page, auth=None) async

Given the prefix of a global display name, returns all users who share that name.

Parameters:

Name Type Description Default
data UserSearchPrefixRequest

The required data for this request.

required
page int

The zero-based page of results you desire.

required
auth Optional[AuthData]

Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

None

Returns:

Type Description
UserSearchResponse

The model which is returned by bungie. General endpoint information.

Source code in src/bungio/api/bungie/user.py
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
async def search_by_global_name_post(
    self, data: UserSearchPrefixRequest, page: int, auth: Optional[AuthData] = None
) -> UserSearchResponse:
    """
    Given the prefix of a global display name, returns all users who share that name.

    Args:
        data: The required data for this request.
        page: The zero-based page of results you desire.
        auth: Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

    Returns:
        The model which is returned by bungie. [General endpoint information.](https://bungie-net.github.io/multi/index.html)
    """

    response = await self._client.http.search_by_global_name_post(
        page=page, auth=auth, **data.to_dict(_return_to_bungie_case=False)
    )
    return await UserSearchResponse.from_dict(data=response, client=self._client, page=page, auth=auth)

search_by_global_name_prefix(display_name_prefix, page, auth=None) async

[OBSOLETE] Do not use this to search users, use SearchByGlobalNamePost instead.

Parameters:

Name Type Description Default
display_name_prefix str

The display name prefix you're looking for.

required
page int

The zero-based page of results you desire.

required
auth Optional[AuthData]

Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

None

Returns:

Type Description
UserSearchResponse

The model which is returned by bungie. General endpoint information.

Source code in src/bungio/api/bungie/user.py
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
async def search_by_global_name_prefix(
    self, display_name_prefix: str, page: int, auth: Optional[AuthData] = None
) -> UserSearchResponse:
    """
    [OBSOLETE] Do not use this to search users, use SearchByGlobalNamePost instead.

    Args:
        display_name_prefix: The display name prefix you're looking for.
        page: The zero-based page of results you desire.
        auth: Authentication information. Required when users with a private profile are queried, or when Bungie feels like it

    Returns:
        The model which is returned by bungie. [General endpoint information.](https://bungie-net.github.io/multi/index.html)
    """

    response = await self._client.http.search_by_global_name_prefix(
        display_name_prefix=display_name_prefix, page=page, auth=auth
    )
    return await UserSearchResponse.from_dict(
        data=response, client=self._client, display_name_prefix=display_name_prefix, page=page, auth=auth
    )