aiobungie.client
A higher-level single process client implementation.
1# MIT License 2# 3# Copyright (c) 2020 - Present nxtlo 4# 5# Permission is hereby granted, free of charge, to any person obtaining a copy 6# of this software and associated documentation files (the "Software"), to deal 7# in the Software without restriction, including without limitation the rights 8# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9# copies of the Software, and to permit persons to whom the Software is 10# furnished to do so, subject to the following conditions: 11# 12# The above copyright notice and this permission notice shall be included in all 13# copies or substantial portions of the Software. 14# 15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21# SOFTWARE. 22 23"""A higher-level single process client implementation.""" 24 25from __future__ import annotations 26 27__all__ = ("Client",) 28 29import typing 30 31import sain 32 33from aiobungie import framework 34from aiobungie import rest as rest_ 35from aiobungie import traits 36from aiobungie.crates import fireteams, user 37from aiobungie.internal import enums, helpers 38 39if typing.TYPE_CHECKING: 40 import collections.abc as collections 41 42 from aiobungie import api, builders 43 from aiobungie.crates import ( 44 activity, 45 application, 46 clans, 47 components, 48 entity, 49 friends, 50 milestones, 51 profile, 52 ) 53 54 55class Client(traits.Compact): 56 """Compact standard client implementation. 57 58 This client is the way to be able to start sending requests over the REST API and receiving deserialized response objects. 59 60 Refer to `aiobungie.RESTClient` if you prefer to use a more lower-level client. 61 62 Example 63 ------- 64 ```py 65 import aiobungie 66 import asyncio 67 68 async def main(): 69 client = aiobungie.Client('token') 70 async with client.rest: 71 user = await client.fetch_bungie_user(20315338) 72 print(user) 73 74 asyncio.run(main()) 75 ``` 76 77 Parameters 78 ----------- 79 token: `str` 80 Your Bungie's API key or Token from the developer's portal. 81 82 Other Parameters 83 ---------------- 84 client_secret : `str | None` 85 An optional application client secret, 86 This is only needed if you're fetching OAuth2 tokens with this client. 87 client_id : `int | None` 88 An optional application client id, 89 This is only needed if you're fetching OAuth2 tokens with this client. 90 settings: `aiobungie.builders.Settings | None` 91 The client settings to use, if `None` the default will be used. 92 max_retries : `int` 93 The max retries number to retry if the request hit a `5xx` status code. 94 debug: `"TRACE" | bool | int` 95 The level of logging to enable. 96 """ 97 98 __slots__ = ("_rest", "_framework") 99 100 def __init__( 101 self, 102 token: str, 103 /, 104 *, 105 client_secret: str | None = None, 106 client_id: int | None = None, 107 settings: builders.Settings | None = None, 108 max_retries: int = 4, 109 debug: typing.Literal["TRACE"] | bool | int = False, 110 ) -> None: 111 self._rest = rest_.RESTClient( 112 token, 113 client_secret=client_secret, 114 client_id=client_id, 115 settings=settings, 116 max_retries=max_retries, 117 debug=debug, 118 ) 119 120 self._framework = framework.Framework() 121 122 @property 123 def framework(self) -> api.Framework: 124 return self._framework 125 126 @property 127 def rest(self) -> api.RESTClient: 128 return self._rest 129 130 @property 131 def metadata(self) -> collections.MutableMapping[typing.Any, typing.Any]: 132 return self._rest.metadata 133 134 @property 135 def settings(self) -> builders.Settings: 136 return self._rest.settings 137 138 # * User methods. 139 140 async def fetch_current_user_memberships(self, access_token: str, /) -> user.User: 141 """Fetch and return a user object of the bungie net user associated with account. 142 143 .. warning:: 144 This method requires OAuth2 scope and a Bearer access token. 145 146 Parameters 147 ---------- 148 access_token : `str` 149 A valid Bearer access token for the authorization. 150 151 Returns 152 ------- 153 `aiobungie.crates.user.User` 154 A user object includes the Destiny memberships and Bungie.net user. 155 """ 156 resp = await self.rest.fetch_current_user_memberships(access_token) 157 158 return self._framework.deserialize_user(resp) 159 160 async def fetch_bungie_user(self, id: int, /) -> user.BungieUser: 161 """Fetch a Bungie user by their BungieNet id. 162 163 Parameters 164 ---------- 165 id: `int` 166 The user id. 167 168 Returns 169 ------- 170 `aiobungie.crates.user.BungieUser` 171 A Bungie user. 172 173 Raises 174 ------ 175 `aiobungie.error.NotFound` 176 The user was not found. 177 """ 178 payload = await self.rest.fetch_bungie_user(id) 179 return self._framework.deserialize_bungie_user(payload) 180 181 async def search_users( 182 self, name: str, / 183 ) -> sain.Iterator[user.SearchableDestinyUser]: 184 """Search for players and return all players that matches the same name. 185 186 Parameters 187 ---------- 188 name : `str` 189 The user name. 190 191 Returns 192 ------- 193 `aiobungie.Iterator[aiobungie.crates.SearchableDestinyUser]` 194 A sequence of the found users with this name. 195 """ 196 payload = await self.rest.search_users(name) 197 return sain.Iter( 198 self._framework.deserialize_searched_user(user) 199 for user in payload["searchResults"] 200 ) 201 202 async def fetch_user_themes(self) -> collections.Sequence[user.UserThemes]: 203 """Fetch all available user themes. 204 205 Returns 206 ------- 207 `collections.Sequence[aiobungie.crates.user.UserThemes]` 208 A sequence of user themes. 209 """ 210 data = await self.rest.fetch_user_themes() 211 212 return self._framework.deserialize_user_themes(data) 213 214 async def fetch_hard_types( 215 self, 216 credential: int, 217 type: enums.CredentialType | int = enums.CredentialType.STEAMID, 218 /, 219 ) -> user.HardLinkedMembership: 220 """Gets any hard linked membership given a credential. 221 222 Only works for credentials that are public just `aiobungie.CredentialType.STEAMID` right now. 223 Cross Save aware. 224 225 Parameters 226 ---------- 227 credential: `int` 228 A valid SteamID64 229 type: `aiobungie.CredentialType` 230 The credential type. This must not be changed 231 Since its only credential that works "currently" 232 233 Returns 234 ------- 235 `aiobungie.crates.user.HardLinkedMembership` 236 Information about the hard linked data. 237 """ 238 239 payload = await self.rest.fetch_hardlinked_credentials(credential, type) 240 241 return user.HardLinkedMembership( 242 id=int(payload["membershipId"]), 243 type=enums.MembershipType(payload["membershipType"]), 244 cross_save_type=enums.MembershipType(payload["CrossSaveOverriddenType"]), 245 ) 246 247 async def fetch_membership_from_id( 248 self, 249 id: int, 250 /, 251 type: enums.MembershipType | int = enums.MembershipType.NONE, 252 ) -> user.User: 253 """Fetch a Bungie user's memberships from their Bungie ID. 254 255 This method returns both Bungie user and its Destiny 2 memberships bound to it. 256 257 Parameters 258 ---------- 259 id : `int` 260 A Bungie.net user's ID. It looks something like this `20315338` 261 type : `aiobungie.MembershipType` 262 The user's membership type. This is optional. 263 264 Returns 265 ------- 266 `aiobungie.crates.User` 267 A Bungie user with their membership types. 268 269 Raises 270 ------ 271 `aiobungie.NotFound` 272 The requested user was not found. 273 """ 274 payload = await self.rest.fetch_membership_from_id(id, type) 275 276 return self._framework.deserialize_user(payload) 277 278 async def fetch_user_credentials( 279 self, access_token: str, membership_id: int, / 280 ) -> collections.Sequence[user.UserCredentials]: 281 """Fetch an array of credential types attached to the requested account. 282 283 .. note:: 284 This method require OAuth2 Bearer access token. 285 286 Parameters 287 ---------- 288 access_token : `str` 289 The bearer access token associated with the bungie account. 290 membership_id : `int` 291 The id of the membership to return. 292 293 Returns 294 ------- 295 `collections.Sequence[aiobungie.crates.UserCredentials]` 296 A sequence of the attached user credentials. 297 298 Raises 299 ------ 300 `aiobungie.Unauthorized` 301 The access token was wrong or no access token passed. 302 """ 303 resp = await self.rest.fetch_user_credentials(access_token, membership_id) 304 305 return self._framework.deserialize_user_credentials(resp) 306 307 async def fetch_sanitized_membership( 308 self, membership_id: int, / 309 ) -> user.SanitizedMembership: 310 """Fetch a list of all display names linked to `membership_id`, Which is profanity filtered. 311 312 Parameters 313 ---------- 314 membership_id: `int` 315 The membership ID to fetch 316 317 Returns 318 ------- 319 `aiobungie.crates.SanitizedMembership` 320 A JSON object contains all the available display names. 321 """ 322 response = await self._rest.fetch_sanitized_membership(membership_id) 323 return self._framework.deserialize_sanitized_membership(response) 324 325 # * Destiny 2. 326 327 async def fetch_profile( 328 self, 329 member_id: int, 330 type: enums.MembershipType | int, 331 components: collections.Sequence[enums.ComponentType], 332 auth: str | None = None, 333 ) -> components.Component: 334 """Fetch a Bungie profile with the required components. 335 336 Example 337 ------- 338 ```py 339 my_profile_id = 4611686018484639825 340 my_profile = await client.fetch_profile( 341 my_profile_id, 342 MembershipType.STEAM, 343 components=(ComponentType.CHARACTERS,) 344 ) 345 characters = my_profile.characters 346 if characters is not None: 347 for character in characters.values(): 348 print(character.power_level) 349 ``` 350 351 Parameters 352 ---------- 353 member_id: `int` 354 The profile membership's id. 355 type: `aiobungie.MembershipType` 356 The profile's membership type. 357 components : `collections.Sequence[aiobungie.ComponentType]` 358 A sequence of components to collect. If the sequence is empty, then all components will be `None`. 359 360 Other Parameters 361 ---------------- 362 auth : `str | None` 363 A Bearer access_token to make the request with. 364 This is optional and limited to components that only requires an Authorization token. 365 366 Returns 367 -------- 368 `aiobungie.crates.Component` 369 A Destiny 2 player profile with its components. 370 Only passed components will be available if they exists. Otherwise they will be `None` 371 372 Raises 373 ------ 374 `aiobungie.MembershipTypeError` 375 The provided membership type was invalid. 376 """ 377 data = await self.rest.fetch_profile(member_id, type, components, auth) 378 return self._framework.deserialize_components(data) 379 380 async def fetch_linked_profiles( 381 self, 382 member_id: int, 383 member_type: enums.MembershipType | int, 384 /, 385 *, 386 all: bool = False, 387 ) -> profile.LinkedProfile: 388 """Returns a summary information about all profiles linked to the requested member. 389 390 The passed membership id/type maybe a Bungie.Net membership or a Destiny memberships. 391 392 .. note:: 393 It will only return linked accounts whose linkages you are allowed to view. 394 395 Parameters 396 ---------- 397 member_id : `int` 398 The ID of the membership. This must be a valid Bungie.Net or PSN or Xbox ID. 399 member_type : `aiobungie.MembershipType` 400 The type for the membership whose linked Destiny account you want to return. 401 402 Other Parameters 403 ---------------- 404 all : `bool` 405 If provided and set to `True`, All memberships regardless 406 of whether they're obscured by overrides will be returned, 407 408 If provided and set to `False`, Only available memberships will be returned. 409 The default for this is `False`. 410 411 Returns 412 ------- 413 `aiobungie.crates.profile.LinkedProfile` 414 A linked profile object. 415 """ 416 resp = await self.rest.fetch_linked_profiles(member_id, member_type, all=all) 417 418 return self._framework.deserialize_linked_profiles(resp) 419 420 async def fetch_membership( 421 self, 422 name: str, 423 code: int, 424 /, 425 type: enums.MembershipType | int = enums.MembershipType.ALL, 426 ) -> collections.Sequence[user.DestinyMembership]: 427 """Fetch a Destiny 2 player's memberships. 428 429 Parameters 430 ----------- 431 name: `str` 432 The unique Bungie player name. 433 code : `int` 434 The unique Bungie display name code. 435 type: `aiobungie.internal.enums.MembershipType` 436 The player's membership type, e,g. XBOX, STEAM, PSN 437 438 Returns 439 -------- 440 `collections.Sequence[aiobungie.crates.DestinyMembership]` 441 A sequence of the found Destiny 2 player memberships. 442 An empty sequence will be returned if no one found. 443 444 Raises 445 ------ 446 `aiobungie.MembershipTypeError` 447 The provided membership type was invalid. 448 """ 449 resp = await self.rest.fetch_membership(name, code, type) 450 451 return self._framework.deserialize_destiny_memberships(resp) 452 453 async def fetch_character( 454 self, 455 member_id: int, 456 membership_type: enums.MembershipType | int, 457 character_id: int, 458 components: collections.Sequence[enums.ComponentType], 459 auth: str | None = None, 460 ) -> components.CharacterComponent: 461 """Fetch a Destiny 2 character. 462 463 Example 464 ------- 465 ```py 466 membership_id, titan_id = 0, 0 467 my_character = await client.fetch_character( 468 membership_id, 469 MembershipType.STEAM, 470 titan_id, 471 components=(ComponentType.CHARACTER_INVENTORIES,) 472 ) 473 inventory = my_character.inventory 474 if inventory is not None: 475 for item in inventory.values(): 476 print(item) 477 ``` 478 479 Parameters 480 ---------- 481 member_id: `int` 482 A valid bungie member id. 483 character_id: `int` 484 The Destiny character id to retrieve. 485 membership_type: `aiobungie.internal.enums.MembershipType` 486 The member's membership type. 487 components: `collections.Sequence[aiobungie.ComponentType]` 488 Multiple arguments of character components to collect and return. 489 490 Other Parameters 491 ---------------- 492 auth : `str | None` 493 A Bearer access_token to make the request with. 494 This is optional and limited to components that only requires an Authorization token. 495 496 Returns 497 ------- 498 `aiobungie.crates.CharacterComponent` 499 A Bungie character component. 500 501 `aiobungie.MembershipTypeError` 502 The provided membership type was invalid. 503 """ 504 resp = await self.rest.fetch_character( 505 member_id, membership_type, character_id, components, auth 506 ) 507 508 return self._framework.deserialize_character_component(resp) 509 510 async def fetch_unique_weapon_history( 511 self, 512 membership_id: int, 513 character_id: int, 514 membership_type: enums.MembershipType | int, 515 ) -> collections.Sequence[activity.ExtendedWeaponValues]: 516 """Fetch details about unique weapon usage for a character. Includes all exotics. 517 518 Parameters 519 ---------- 520 membership_id : `int` 521 The Destiny user membership id. 522 character_id : `int` 523 The character id to retrieve. 524 membership_type : `aiobungie.aiobungie.MembershipType | int` 525 The Destiny user's membership type. 526 527 Returns 528 ------- 529 `collections.Sequence[aiobungie.crates.ExtendedWeaponValues]` 530 A sequence of the weapon's extended values. 531 """ 532 resp = await self._rest.fetch_unique_weapon_history( 533 membership_id, character_id, membership_type 534 ) 535 536 return tuple( 537 self._framework.deserialize_extended_weapon_values(weapon) 538 for weapon in resp["weapons"] 539 ) 540 541 # * Destiny 2 Activities. 542 543 async def fetch_activities( 544 self, 545 member_id: int, 546 character_id: int, 547 mode: enums.GameMode | int, 548 *, 549 membership_type: enums.MembershipType | int = enums.MembershipType.ALL, 550 page: int = 0, 551 limit: int = 250, 552 ) -> sain.Iterator[activity.Activity]: 553 """Fetch a Destiny 2 activity for the specified character id. 554 555 Parameters 556 ---------- 557 member_id: `int` 558 The user id that starts with `4611`. 559 character_id: `int` 560 The id of the character to retrieve the activities for. 561 mode: `aiobungie.aiobungie.internal.enums.GameMode | int` 562 This parameter filters the game mode, Nightfall, Strike, Iron Banner, etc. 563 564 Other Parameters 565 ---------------- 566 membership_type: `aiobungie.internal.enums.MembershipType` 567 The Member ship type, if nothing was passed than it will return all. 568 page: int 569 The page number. Default is `0` 570 limit: int 571 Limit the returned result. Default is `250`. 572 573 Returns 574 ------- 575 `Iterator[aiobungie.crates.Activity]` 576 An iterator of the player's activities. 577 578 Raises 579 ------ 580 `aiobungie.MembershipTypeError` 581 The provided membership type was invalid. 582 """ 583 resp = await self.rest.fetch_activities( 584 member_id, 585 character_id, 586 mode, 587 membership_type=membership_type, 588 page=page, 589 limit=limit, 590 ) 591 592 return self._framework.deserialize_activities(resp) 593 594 async def fetch_post_activity(self, instance_id: int, /) -> activity.PostActivity: 595 """Fetch a post activity details. 596 597 Parameters 598 ---------- 599 instance_id: `int` 600 The activity instance id. 601 602 Returns 603 ------- 604 `aiobungie.crates.PostActivity` 605 A post activity object. 606 """ 607 resp = await self.rest.fetch_post_activity(instance_id) 608 609 return self._framework.deserialize_post_activity(resp) 610 611 async def fetch_aggregated_activity_stats( 612 self, 613 character_id: int, 614 membership_id: int, 615 membership_type: enums.MembershipType | int, 616 ) -> sain.Iterator[activity.AggregatedActivity]: 617 """Fetch aggregated activity stats for a character. 618 619 Parameters 620 ---------- 621 character_id: `int` 622 The id of the character to retrieve the activities for. 623 membership_id: `int` 624 The id of the user that started with `4611`. 625 membership_type: `aiobungie.internal.enums.MembershipType` 626 The Member ship type. 627 628 Returns 629 ------- 630 `Iterator[aiobungie.crates.AggregatedActivity]` 631 An iterator of the player's activities. 632 633 Raises 634 ------ 635 `aiobungie.MembershipTypeError` 636 The provided membership type was invalid. 637 """ 638 resp = await self.rest.fetch_aggregated_activity_stats( 639 character_id, membership_id, membership_type 640 ) 641 642 return self._framework.deserialize_aggregated_activities(resp) 643 644 # * Destiny 2 Clans or GroupsV2. 645 646 async def fetch_clan_from_id( 647 self, 648 id: int, 649 /, 650 access_token: str | None = None, 651 ) -> clans.Clan: 652 """Fetch a Bungie Clan by its id. 653 654 Parameters 655 ----------- 656 id: `int` 657 The clan id. 658 659 Returns 660 -------- 661 `aiobungie.crates.Clan` 662 An Bungie clan. 663 664 Raises 665 ------ 666 `aiobungie.NotFound` 667 The clan was not found. 668 """ 669 resp = await self.rest.fetch_clan_from_id(id, access_token) 670 671 return self._framework.deserialize_clan(resp) 672 673 async def fetch_clan( 674 self, 675 name: str, 676 /, 677 access_token: str | None = None, 678 *, 679 type: enums.GroupType | int = enums.GroupType.CLAN, 680 ) -> clans.Clan: 681 """Fetch a Clan by its name. 682 This method will return the first clan found with given name. 683 684 Parameters 685 ---------- 686 name: `str` 687 The clan name 688 689 Other Parameters 690 ---------------- 691 access_token : `str | None` 692 An optional access token to make the request with. 693 694 If the token was bound to a member of the clan, 695 This field `aiobungie.crates.Clan.current_user_membership` will be available 696 and will return the membership of the user who made this request. 697 type : `aiobungie.GroupType` 698 The group type, Default is aiobungie.GroupType.CLAN. 699 700 Returns 701 ------- 702 `aiobungie.crates.Clan` 703 A Bungie clan. 704 705 Raises 706 ------ 707 `aiobungie.NotFound` 708 The clan was not found. 709 """ 710 resp = await self.rest.fetch_clan(name, access_token, type=type) 711 712 return self._framework.deserialize_clan(resp) 713 714 async def fetch_clan_conversations( 715 self, clan_id: int, / 716 ) -> collections.Sequence[clans.ClanConversation]: 717 """Fetch the conversations/chat channels of the given clan id. 718 719 Parameters 720 ---------- 721 clan_id : `int` 722 The clan id. 723 724 Returns 725 `collections.Sequence[aiobungie.crates.ClanConversation]` 726 A sequence of the clan chat channels. 727 """ 728 resp = await self.rest.fetch_clan_conversations(clan_id) 729 730 return self._framework.deserialize_clan_conversations(resp) 731 732 async def fetch_clan_admins( 733 self, clan_id: int, / 734 ) -> sain.Iterator[clans.ClanMember]: 735 """Fetch the clan founder and admins. 736 737 Parameters 738 ---------- 739 clan_id : `int` 740 The clan id. 741 742 Returns 743 ------- 744 `aiobungie.Iterator[aiobungie.crates.ClanMember]` 745 An iterator over the found clan admins and founder. 746 747 Raises 748 ------ 749 `aiobungie.NotFound` 750 The requested clan was not found. 751 """ 752 resp = await self.rest.fetch_clan_admins(clan_id) 753 754 return self._framework.deserialize_clan_members(resp) 755 756 async def fetch_groups_for_member( 757 self, 758 member_id: int, 759 member_type: enums.MembershipType | int, 760 /, 761 *, 762 filter: int = 0, 763 group_type: enums.GroupType = enums.GroupType.CLAN, 764 ) -> collections.Sequence[clans.GroupMember]: 765 """Fetch information about the groups that a given member has joined. 766 767 Parameters 768 ---------- 769 member_id : `int` 770 The member's id 771 member_type : `aiobungie.MembershipType` 772 The member's membership type. 773 774 Other Parameters 775 ---------------- 776 filter : `int` 777 Filter apply to list of joined groups. This Default to `0` 778 group_type : `aiobungie.GroupType` 779 The group's type. 780 This is always set to `aiobungie.GroupType.CLAN` and should not be changed. 781 782 Returns 783 ------- 784 `collections.Sequence[aiobungie.crates.GroupMember]` 785 A sequence of joined groups for the fetched member. 786 """ 787 resp = await self.rest.fetch_groups_for_member( 788 member_id, member_type, filter=filter, group_type=group_type 789 ) 790 791 return tuple( 792 self._framework.deserialize_group_member(group) for group in resp["results"] 793 ) 794 795 async def fetch_potential_groups_for_member( 796 self, 797 member_id: int, 798 member_type: enums.MembershipType | int, 799 /, 800 *, 801 filter: int = 0, 802 group_type: enums.GroupType | int = enums.GroupType.CLAN, 803 ) -> collections.Sequence[clans.GroupMember]: 804 """Fetch the potential groups for a clan member. 805 806 Parameters 807 ---------- 808 member_id : `int` 809 The member's id 810 member_type : `aiobungie.aiobungie.MembershipType | int` 811 The member's membership type. 812 813 Other Parameters 814 ---------------- 815 filter : `int` 816 Filter apply to list of joined groups. This Default to `0` 817 group_type : `aiobungie.aiobungie.GroupType | int` 818 The group's type. 819 This is always set to `aiobungie.GroupType.CLAN` and should not be changed. 820 821 Returns 822 ------- 823 `collections.Sequence[aiobungie.crates.GroupMember]` 824 A sequence of joined potential groups for the fetched member. 825 """ 826 resp = await self.rest.fetch_potential_groups_for_member( 827 member_id, member_type, filter=filter, group_type=group_type 828 ) 829 830 return tuple( 831 self._framework.deserialize_group_member(group) for group in resp["results"] 832 ) 833 834 async def fetch_clan_members( 835 self, 836 clan_id: int, 837 /, 838 *, 839 name: str | None = None, 840 type: enums.MembershipType | int = enums.MembershipType.NONE, 841 ) -> sain.Iterator[clans.ClanMember]: 842 """Fetch Bungie clan members. 843 844 Parameters 845 ---------- 846 clan_id : `int` 847 The clans id 848 849 Other Parameters 850 ---------------- 851 name : `str | None` 852 If provided, Only players matching this name will be returned. 853 type : `aiobungie.MembershipType` 854 An optional clan member's membership type. 855 This parameter is used to filter the returned results 856 by the provided membership, For an example XBox memberships only, 857 Otherwise will return all memberships. 858 859 Returns 860 ------- 861 `Iterator[aiobungie.crates.ClanMember]` 862 An iterator over the bungie clan members. 863 864 Raises 865 ------ 866 `aiobungie.NotFound` 867 The clan was not found. 868 """ 869 resp = await self.rest.fetch_clan_members(clan_id, type=type, name=name) 870 871 return self._framework.deserialize_clan_members(resp) 872 873 async def fetch_clan_banners(self) -> collections.Sequence[clans.ClanBanner]: 874 """Fetch the clan banners. 875 876 Returns 877 ------- 878 `collections.Sequence[aiobungie.crates.ClanBanner]` 879 A sequence of the clan banners. 880 """ 881 resp = await self.rest.fetch_clan_banners() 882 883 return self._framework.deserialize_clan_banners(resp) 884 885 # This method is required to be here since it deserialize the clan. 886 async def kick_clan_member( 887 self, 888 access_token: str, 889 /, 890 group_id: int, 891 membership_id: int, 892 membership_type: enums.MembershipType | int, 893 ) -> clans.Clan: 894 """Kick a member from the clan. 895 896 .. note:: 897 This request requires OAuth2: oauth2: `AdminGroups` scope. 898 899 Parameters 900 ---------- 901 access_token : `str` 902 The bearer access token associated with the bungie account. 903 group_id: `int` 904 The group id. 905 membership_id : `int` 906 The member id to kick. 907 membership_type : `aiobungie.aiobungie.MembershipType | int` 908 The member's membership type. 909 910 Returns 911 ------- 912 `aiobungie.crates.clan.Clan` 913 The clan that the member was kicked from. 914 """ 915 resp = await self.rest.kick_clan_member( 916 access_token, 917 group_id=group_id, 918 membership_id=membership_id, 919 membership_type=membership_type, 920 ) 921 922 return self._framework.deserialize_clan(resp) 923 924 async def fetch_clan_weekly_rewards(self, clan_id: int) -> milestones.Milestone: 925 """Fetch a Bungie clan's weekly reward state. 926 927 Parameters 928 ---------- 929 clan_id : `int` 930 The clan's id. 931 932 Returns 933 ------- 934 `aiobungie.crates.Milestone` 935 A runtime status of the clan's milestone data. 936 """ 937 938 resp = await self.rest.fetch_clan_weekly_rewards(clan_id) 939 940 return self._framework.deserialize_milestone(resp) 941 942 async def search_group( 943 self, 944 name: str, 945 group_type: enums.GroupType | int, 946 *, 947 creation_date: clans.GroupDate | int = 0, 948 sort_by: int | None = None, 949 group_member_count_filter: typing.Literal[0, 1, 2, 3] | None = None, 950 locale_filter: str | None = None, 951 tag_text: str | None = None, 952 items_per_page: int | None = None, 953 current_page: int | None = None, 954 request_token: str | None = None, 955 ) -> collections.Sequence[clans.Group]: 956 """Search for groups. 957 958 .. note:: 959 If the group type is set to `CLAN`, then parameters `group_member_count_filter`, 960 `locale_filter` and `tag_text` must be `None`, otherwise `ValueError` will be raised. 961 962 Parameters 963 ---------- 964 name : `str` 965 The group name. 966 group_type : `aiobungie.GroupType | int` 967 The group type that's being searched for. 968 969 Other Parameters 970 ---------------- 971 creation_date : `aiobungie.GroupDate | int` 972 The creation date of the group. Defaults to `0` which is all time. 973 sort_by : `int | None` 974 ... 975 group_member_count_filter : `int | None` 976 ... 977 locale_filter : `str | None` 978 ... 979 tag_text : `str | None` 980 ... 981 items_per_page : `int | None` 982 ... 983 current_page : `int | None` 984 ... 985 request_token : `str | None` 986 ... 987 988 Returns 989 -------- 990 `collections.Sequence[aiobungie.crates.Group]` 991 An array that contains the groups that match the search criteria. 992 993 Raises 994 ------ 995 `ValueError` 996 If the group type is `aiobungie.GroupType.CLAN` and `group_member_count_filter`, 997 `locale_filter` and `tag_text` are not `None`. 998 """ 999 response = await self._rest.search_group( 1000 name, 1001 group_type, 1002 sort_by=sort_by, 1003 creation_date=creation_date, 1004 group_member_count_filter=group_member_count_filter, 1005 locale_filter=locale_filter, 1006 tag_text=tag_text, 1007 items_per_page=items_per_page, 1008 current_page=current_page, 1009 request_token=request_token, 1010 ) 1011 return tuple( 1012 self._framework.deserialize_group(result) for result in response["results"] 1013 ) 1014 1015 # * Destiny 2 Entities aka Definitions. 1016 1017 async def fetch_inventory_item(self, hash: int, /) -> entity.InventoryEntity: 1018 """Fetch a static inventory item entity given a its hash. 1019 1020 Parameters 1021 ---------- 1022 hash: `int` 1023 Inventory item's hash. 1024 1025 Returns 1026 ------- 1027 `aiobungie.crates.InventoryEntity` 1028 A bungie inventory item. 1029 """ 1030 resp = await self.rest.fetch_inventory_item(hash) 1031 1032 return self._framework.deserialize_inventory_entity(resp) 1033 1034 async def fetch_objective_entity(self, hash: int, /) -> entity.ObjectiveEntity: 1035 """Fetch a Destiny objective entity given a its hash. 1036 1037 Parameters 1038 ---------- 1039 hash: `int` 1040 objective's hash. 1041 1042 Returns 1043 ------- 1044 `aiobungie.crates.ObjectiveEntity` 1045 An objective entity item. 1046 """ 1047 resp = await self.rest.fetch_objective_entity(hash) 1048 1049 return self._framework.deserialize_objective_entity(resp) 1050 1051 @helpers.unstable 1052 async def search_entities( 1053 self, name: str, entity_type: str, *, page: int = 0 1054 ) -> sain.Iterator[entity.SearchableEntity]: 1055 """Search for Destiny2 entities given a name and its type. 1056 1057 Parameters 1058 ---------- 1059 name : `str` 1060 The name of the entity, i.e., Thunderlord, One thousand voices. 1061 entity_type : `str` 1062 The type of the entity, AKA Definition, 1063 For an example `DestinyInventoryItemDefinition` for emblems, weapons, and other inventory items. 1064 1065 Other Parameters 1066 ---------------- 1067 page : `int` 1068 An optional page to return. Default to 0. 1069 1070 Returns 1071 ------- 1072 `Iterator[aiobungie.crates.SearchableEntity]` 1073 An iterator over the found results matching the provided name. 1074 """ 1075 # resp = await self.rest.search_entities(name, entity_type, page=page) 1076 # calling this method will raise anyways. 1077 raise 1078 1079 # Fireteams 1080 1081 async def fetch_fireteams( 1082 self, 1083 activity_type: fireteams.FireteamActivity | int, 1084 *, 1085 platform: fireteams.FireteamPlatform | int = fireteams.FireteamPlatform.ANY, 1086 language: fireteams.FireteamLanguage | str = fireteams.FireteamLanguage.ALL, 1087 date_range: int = 0, 1088 page: int = 0, 1089 slots_filter: int = 0, 1090 ) -> collections.Sequence[fireteams.Fireteam]: 1091 """Fetch public Bungie fireteams with open slots. 1092 1093 Parameters 1094 ---------- 1095 activity_type : `aiobungie.aiobungie.crates.FireteamActivity | int` 1096 The fireteam activity type. 1097 1098 Other Parameters 1099 ---------------- 1100 platform : `aiobungie.aiobungie.crates.fireteams.FireteamPlatform | int` 1101 If this is provided. Then the results will be filtered with the given platform. 1102 Defaults to `aiobungie.crates.FireteamPlatform.ANY` which returns all platforms. 1103 language : `aiobungie.crates.fireteams.FireteamLanguage | str` 1104 A locale language to filter the used language in that fireteam. 1105 Defaults to `aiobungie.crates.FireteamLanguage.ALL` 1106 date_range : `int` 1107 An integer to filter the date range of the returned fireteams. Defaults to `aiobungie.FireteamDate.ALL`. 1108 page : `int` 1109 The page number. By default its `0` which returns all available activities. 1110 slots_filter : `int` 1111 Filter the returned fireteams based on available slots. Default is `0` 1112 1113 Returns 1114 ------- 1115 `collections.Sequence[fireteams.Fireteam]` 1116 A sequence of `aiobungie.crates.Fireteam`. 1117 """ 1118 1119 resp = await self.rest.fetch_fireteams( 1120 activity_type, 1121 platform=platform, 1122 language=language, 1123 date_range=date_range, 1124 page=page, 1125 slots_filter=slots_filter, 1126 ) 1127 1128 return self._framework.deserialize_fireteams(resp) 1129 1130 async def fetch_available_clan_fireteams( 1131 self, 1132 access_token: str, 1133 group_id: int, 1134 activity_type: fireteams.FireteamActivity | int, 1135 *, 1136 platform: fireteams.FireteamPlatform | int, 1137 language: fireteams.FireteamLanguage | str, 1138 date_range: int = 0, 1139 page: int = 0, 1140 public_only: bool = False, 1141 slots_filter: int = 0, 1142 ) -> collections.Sequence[fireteams.Fireteam]: 1143 """Fetch a clan's fireteams with open slots. 1144 1145 .. note:: 1146 This method requires OAuth2: ReadGroups scope. 1147 1148 Parameters 1149 ---------- 1150 access_token : `str` 1151 The bearer access token associated with the bungie account. 1152 group_id : `int` 1153 The group/clan id of the fireteam. 1154 activity_type : `aiobungie.aiobungie.crates.FireteamActivity | int` 1155 The fireteam activity type. 1156 1157 Other Parameters 1158 ---------------- 1159 platform : `aiobungie.aiobungie.crates.fireteams.FireteamPlatform | int` 1160 If this is provided. Then the results will be filtered with the given platform. 1161 Defaults to `aiobungie.crates.FireteamPlatform.ANY` which returns all platforms. 1162 language : `aiobungie.crates.fireteams.FireteamLanguage | str` 1163 A locale language to filter the used language in that fireteam. 1164 Defaults to `aiobungie.crates.FireteamLanguage.ALL` 1165 date_range : `int` 1166 An integer to filter the date range of the returned fireteams. Defaults to `0`. 1167 page : `int` 1168 The page number. By default its `0` which returns all available activities. 1169 public_only: `bool` 1170 If set to True, Then only public fireteams will be returned. 1171 slots_filter : `int` 1172 Filter the returned fireteams based on available slots. Default is `0` 1173 1174 Returns 1175 ------- 1176 `collections.Sequence[aiobungie.crates.Fireteam]` 1177 A sequence of fireteams found in the clan. 1178 `None` will be returned if nothing was found. 1179 """ 1180 resp = await self.rest.fetch_available_clan_fireteams( 1181 access_token, 1182 group_id, 1183 activity_type, 1184 platform=platform, 1185 language=language, 1186 date_range=date_range, 1187 page=page, 1188 public_only=public_only, 1189 slots_filter=slots_filter, 1190 ) 1191 1192 return self._framework.deserialize_fireteams(resp) 1193 1194 async def fetch_clan_fireteam( 1195 self, access_token: str, fireteam_id: int, group_id: int 1196 ) -> fireteams.AvailableFireteam: 1197 """Fetch a specific clan fireteam. 1198 1199 .. note:: 1200 This method requires OAuth2: ReadGroups scope. 1201 1202 Parameters 1203 ---------- 1204 access_token : `str` 1205 The bearer access token associated with the bungie account. 1206 group_id : `int` 1207 The group/clan id to fetch the fireteam from. 1208 fireteam_id : `int` 1209 The fireteam id to fetch. 1210 1211 Returns 1212 ------- 1213 `aiobungie.crates.AvailableFireteam` 1214 A sequence of available fireteams objects. 1215 """ 1216 resp = await self.rest.fetch_clan_fireteam(access_token, fireteam_id, group_id) 1217 1218 return self._framework.deserialize_available_fireteam(resp) 1219 1220 async def fetch_my_clan_fireteams( 1221 self, 1222 access_token: str, 1223 group_id: int, 1224 *, 1225 include_closed: bool = True, 1226 platform: fireteams.FireteamPlatform | int, 1227 language: fireteams.FireteamLanguage | str, 1228 filtered: bool = True, 1229 page: int = 0, 1230 ) -> collections.Sequence[fireteams.AvailableFireteam]: 1231 """A method that's similar to `fetch_fireteams` but requires OAuth2. 1232 1233 .. note:: 1234 This method requires OAuth2: ReadGroups scope. 1235 1236 Parameters 1237 ---------- 1238 access_token : str 1239 The bearer access token associated with the bungie account. 1240 group_id : int 1241 The group/clan id to fetch. 1242 1243 Other Parameters 1244 ---------------- 1245 include_closed : `bool` 1246 If provided and set to True, It will also return closed fireteams. 1247 If provided and set to False, It will only return public fireteams. Default is True. 1248 platform : aiobungie.aiobungie.crates.fireteams.FireteamPlatform | int 1249 If this is provided. Then the results will be filtered with the given platform. 1250 Defaults to aiobungie.crates.FireteamPlatform.ANY which returns all platforms. 1251 language : `aiobungie.crates.fireteams.FireteamLanguage | str` 1252 A locale language to filter the used language in that fireteam. 1253 Defaults to aiobungie.crates.FireteamLanguage.ALL 1254 filtered : `bool` 1255 If set to True, it will filter by clan. Otherwise not. Default is True. 1256 page : `int` 1257 The page number. By default its 0 which returns all available activities. 1258 1259 Returns 1260 ------- 1261 `collections.Sequence[aiobungie.crates.AvailableFireteam]` 1262 A sequence of available fireteams objects if exists. else `None` will be returned. 1263 """ 1264 resp = await self.rest.fetch_my_clan_fireteams( 1265 access_token, 1266 group_id, 1267 include_closed=include_closed, 1268 platform=platform, 1269 language=language, 1270 filtered=filtered, 1271 page=page, 1272 ) 1273 1274 return self._framework.deserialize_available_fireteams(resp) 1275 1276 # Friends and social. 1277 1278 async def fetch_friends( 1279 self, access_token: str, / 1280 ) -> collections.Sequence[friends.Friend]: 1281 """Fetch bungie friend list. 1282 1283 .. note:: 1284 This requests OAuth2: ReadUserData scope. 1285 1286 Parameters 1287 ----------- 1288 access_token : `str` 1289 The bearer access token associated with the bungie account. 1290 1291 Returns 1292 ------- 1293 `collections.Sequence[aiobungie.crates.Friend]` 1294 A sequence of the friends associated with that access token. 1295 """ 1296 1297 resp = await self.rest.fetch_friends(access_token) 1298 1299 return self._framework.deserialize_friends(resp) 1300 1301 async def fetch_friend_requests( 1302 self, access_token: str, / 1303 ) -> friends.FriendRequestView: 1304 """Fetch pending bungie friend requests queue. 1305 1306 .. note:: 1307 This requests OAuth2: ReadUserData scope. 1308 1309 Parameters 1310 ----------- 1311 access_token : `str` 1312 The bearer access token associated with the bungie account. 1313 1314 Returns 1315 ------- 1316 `aiobungie.crates.FriendRequestView` 1317 A friend requests view of that associated access token. 1318 """ 1319 1320 resp = await self.rest.fetch_friend_requests(access_token) 1321 1322 return self._framework.deserialize_friend_requests(resp) 1323 1324 # Applications and Developer portal. 1325 1326 async def fetch_application(self, appid: int, /) -> application.Application: 1327 """Fetch a Bungie application. 1328 1329 Parameters 1330 ----------- 1331 appid: `int` 1332 The application id. 1333 1334 Returns 1335 -------- 1336 `aiobungie.crates.Application` 1337 A Bungie application. 1338 """ 1339 resp = await self.rest.fetch_application(appid) 1340 1341 return self._framework.deserialize_application(resp) 1342 1343 # Milestones 1344 1345 async def fetch_public_milestone_content( 1346 self, milestone_hash: int, / 1347 ) -> milestones.MilestoneContent: 1348 """Fetch the milestone content given its hash. 1349 1350 Parameters 1351 ---------- 1352 milestone_hash : `int` 1353 The milestone hash. 1354 1355 Returns 1356 ------- 1357 `aiobungie.crates.milestones.MilestoneContent` 1358 A milestone content object. 1359 """ 1360 ... 1361 resp = await self.rest.fetch_public_milestone_content(milestone_hash) 1362 return self._framework.deserialize_public_milestone_content(resp)
56class Client(traits.Compact): 57 """Compact standard client implementation. 58 59 This client is the way to be able to start sending requests over the REST API and receiving deserialized response objects. 60 61 Refer to `aiobungie.RESTClient` if you prefer to use a more lower-level client. 62 63 Example 64 ------- 65 ```py 66 import aiobungie 67 import asyncio 68 69 async def main(): 70 client = aiobungie.Client('token') 71 async with client.rest: 72 user = await client.fetch_bungie_user(20315338) 73 print(user) 74 75 asyncio.run(main()) 76 ``` 77 78 Parameters 79 ----------- 80 token: `str` 81 Your Bungie's API key or Token from the developer's portal. 82 83 Other Parameters 84 ---------------- 85 client_secret : `str | None` 86 An optional application client secret, 87 This is only needed if you're fetching OAuth2 tokens with this client. 88 client_id : `int | None` 89 An optional application client id, 90 This is only needed if you're fetching OAuth2 tokens with this client. 91 settings: `aiobungie.builders.Settings | None` 92 The client settings to use, if `None` the default will be used. 93 max_retries : `int` 94 The max retries number to retry if the request hit a `5xx` status code. 95 debug: `"TRACE" | bool | int` 96 The level of logging to enable. 97 """ 98 99 __slots__ = ("_rest", "_framework") 100 101 def __init__( 102 self, 103 token: str, 104 /, 105 *, 106 client_secret: str | None = None, 107 client_id: int | None = None, 108 settings: builders.Settings | None = None, 109 max_retries: int = 4, 110 debug: typing.Literal["TRACE"] | bool | int = False, 111 ) -> None: 112 self._rest = rest_.RESTClient( 113 token, 114 client_secret=client_secret, 115 client_id=client_id, 116 settings=settings, 117 max_retries=max_retries, 118 debug=debug, 119 ) 120 121 self._framework = framework.Framework() 122 123 @property 124 def framework(self) -> api.Framework: 125 return self._framework 126 127 @property 128 def rest(self) -> api.RESTClient: 129 return self._rest 130 131 @property 132 def metadata(self) -> collections.MutableMapping[typing.Any, typing.Any]: 133 return self._rest.metadata 134 135 @property 136 def settings(self) -> builders.Settings: 137 return self._rest.settings 138 139 # * User methods. 140 141 async def fetch_current_user_memberships(self, access_token: str, /) -> user.User: 142 """Fetch and return a user object of the bungie net user associated with account. 143 144 .. warning:: 145 This method requires OAuth2 scope and a Bearer access token. 146 147 Parameters 148 ---------- 149 access_token : `str` 150 A valid Bearer access token for the authorization. 151 152 Returns 153 ------- 154 `aiobungie.crates.user.User` 155 A user object includes the Destiny memberships and Bungie.net user. 156 """ 157 resp = await self.rest.fetch_current_user_memberships(access_token) 158 159 return self._framework.deserialize_user(resp) 160 161 async def fetch_bungie_user(self, id: int, /) -> user.BungieUser: 162 """Fetch a Bungie user by their BungieNet id. 163 164 Parameters 165 ---------- 166 id: `int` 167 The user id. 168 169 Returns 170 ------- 171 `aiobungie.crates.user.BungieUser` 172 A Bungie user. 173 174 Raises 175 ------ 176 `aiobungie.error.NotFound` 177 The user was not found. 178 """ 179 payload = await self.rest.fetch_bungie_user(id) 180 return self._framework.deserialize_bungie_user(payload) 181 182 async def search_users( 183 self, name: str, / 184 ) -> sain.Iterator[user.SearchableDestinyUser]: 185 """Search for players and return all players that matches the same name. 186 187 Parameters 188 ---------- 189 name : `str` 190 The user name. 191 192 Returns 193 ------- 194 `aiobungie.Iterator[aiobungie.crates.SearchableDestinyUser]` 195 A sequence of the found users with this name. 196 """ 197 payload = await self.rest.search_users(name) 198 return sain.Iter( 199 self._framework.deserialize_searched_user(user) 200 for user in payload["searchResults"] 201 ) 202 203 async def fetch_user_themes(self) -> collections.Sequence[user.UserThemes]: 204 """Fetch all available user themes. 205 206 Returns 207 ------- 208 `collections.Sequence[aiobungie.crates.user.UserThemes]` 209 A sequence of user themes. 210 """ 211 data = await self.rest.fetch_user_themes() 212 213 return self._framework.deserialize_user_themes(data) 214 215 async def fetch_hard_types( 216 self, 217 credential: int, 218 type: enums.CredentialType | int = enums.CredentialType.STEAMID, 219 /, 220 ) -> user.HardLinkedMembership: 221 """Gets any hard linked membership given a credential. 222 223 Only works for credentials that are public just `aiobungie.CredentialType.STEAMID` right now. 224 Cross Save aware. 225 226 Parameters 227 ---------- 228 credential: `int` 229 A valid SteamID64 230 type: `aiobungie.CredentialType` 231 The credential type. This must not be changed 232 Since its only credential that works "currently" 233 234 Returns 235 ------- 236 `aiobungie.crates.user.HardLinkedMembership` 237 Information about the hard linked data. 238 """ 239 240 payload = await self.rest.fetch_hardlinked_credentials(credential, type) 241 242 return user.HardLinkedMembership( 243 id=int(payload["membershipId"]), 244 type=enums.MembershipType(payload["membershipType"]), 245 cross_save_type=enums.MembershipType(payload["CrossSaveOverriddenType"]), 246 ) 247 248 async def fetch_membership_from_id( 249 self, 250 id: int, 251 /, 252 type: enums.MembershipType | int = enums.MembershipType.NONE, 253 ) -> user.User: 254 """Fetch a Bungie user's memberships from their Bungie ID. 255 256 This method returns both Bungie user and its Destiny 2 memberships bound to it. 257 258 Parameters 259 ---------- 260 id : `int` 261 A Bungie.net user's ID. It looks something like this `20315338` 262 type : `aiobungie.MembershipType` 263 The user's membership type. This is optional. 264 265 Returns 266 ------- 267 `aiobungie.crates.User` 268 A Bungie user with their membership types. 269 270 Raises 271 ------ 272 `aiobungie.NotFound` 273 The requested user was not found. 274 """ 275 payload = await self.rest.fetch_membership_from_id(id, type) 276 277 return self._framework.deserialize_user(payload) 278 279 async def fetch_user_credentials( 280 self, access_token: str, membership_id: int, / 281 ) -> collections.Sequence[user.UserCredentials]: 282 """Fetch an array of credential types attached to the requested account. 283 284 .. note:: 285 This method require OAuth2 Bearer access token. 286 287 Parameters 288 ---------- 289 access_token : `str` 290 The bearer access token associated with the bungie account. 291 membership_id : `int` 292 The id of the membership to return. 293 294 Returns 295 ------- 296 `collections.Sequence[aiobungie.crates.UserCredentials]` 297 A sequence of the attached user credentials. 298 299 Raises 300 ------ 301 `aiobungie.Unauthorized` 302 The access token was wrong or no access token passed. 303 """ 304 resp = await self.rest.fetch_user_credentials(access_token, membership_id) 305 306 return self._framework.deserialize_user_credentials(resp) 307 308 async def fetch_sanitized_membership( 309 self, membership_id: int, / 310 ) -> user.SanitizedMembership: 311 """Fetch a list of all display names linked to `membership_id`, Which is profanity filtered. 312 313 Parameters 314 ---------- 315 membership_id: `int` 316 The membership ID to fetch 317 318 Returns 319 ------- 320 `aiobungie.crates.SanitizedMembership` 321 A JSON object contains all the available display names. 322 """ 323 response = await self._rest.fetch_sanitized_membership(membership_id) 324 return self._framework.deserialize_sanitized_membership(response) 325 326 # * Destiny 2. 327 328 async def fetch_profile( 329 self, 330 member_id: int, 331 type: enums.MembershipType | int, 332 components: collections.Sequence[enums.ComponentType], 333 auth: str | None = None, 334 ) -> components.Component: 335 """Fetch a Bungie profile with the required components. 336 337 Example 338 ------- 339 ```py 340 my_profile_id = 4611686018484639825 341 my_profile = await client.fetch_profile( 342 my_profile_id, 343 MembershipType.STEAM, 344 components=(ComponentType.CHARACTERS,) 345 ) 346 characters = my_profile.characters 347 if characters is not None: 348 for character in characters.values(): 349 print(character.power_level) 350 ``` 351 352 Parameters 353 ---------- 354 member_id: `int` 355 The profile membership's id. 356 type: `aiobungie.MembershipType` 357 The profile's membership type. 358 components : `collections.Sequence[aiobungie.ComponentType]` 359 A sequence of components to collect. If the sequence is empty, then all components will be `None`. 360 361 Other Parameters 362 ---------------- 363 auth : `str | None` 364 A Bearer access_token to make the request with. 365 This is optional and limited to components that only requires an Authorization token. 366 367 Returns 368 -------- 369 `aiobungie.crates.Component` 370 A Destiny 2 player profile with its components. 371 Only passed components will be available if they exists. Otherwise they will be `None` 372 373 Raises 374 ------ 375 `aiobungie.MembershipTypeError` 376 The provided membership type was invalid. 377 """ 378 data = await self.rest.fetch_profile(member_id, type, components, auth) 379 return self._framework.deserialize_components(data) 380 381 async def fetch_linked_profiles( 382 self, 383 member_id: int, 384 member_type: enums.MembershipType | int, 385 /, 386 *, 387 all: bool = False, 388 ) -> profile.LinkedProfile: 389 """Returns a summary information about all profiles linked to the requested member. 390 391 The passed membership id/type maybe a Bungie.Net membership or a Destiny memberships. 392 393 .. note:: 394 It will only return linked accounts whose linkages you are allowed to view. 395 396 Parameters 397 ---------- 398 member_id : `int` 399 The ID of the membership. This must be a valid Bungie.Net or PSN or Xbox ID. 400 member_type : `aiobungie.MembershipType` 401 The type for the membership whose linked Destiny account you want to return. 402 403 Other Parameters 404 ---------------- 405 all : `bool` 406 If provided and set to `True`, All memberships regardless 407 of whether they're obscured by overrides will be returned, 408 409 If provided and set to `False`, Only available memberships will be returned. 410 The default for this is `False`. 411 412 Returns 413 ------- 414 `aiobungie.crates.profile.LinkedProfile` 415 A linked profile object. 416 """ 417 resp = await self.rest.fetch_linked_profiles(member_id, member_type, all=all) 418 419 return self._framework.deserialize_linked_profiles(resp) 420 421 async def fetch_membership( 422 self, 423 name: str, 424 code: int, 425 /, 426 type: enums.MembershipType | int = enums.MembershipType.ALL, 427 ) -> collections.Sequence[user.DestinyMembership]: 428 """Fetch a Destiny 2 player's memberships. 429 430 Parameters 431 ----------- 432 name: `str` 433 The unique Bungie player name. 434 code : `int` 435 The unique Bungie display name code. 436 type: `aiobungie.internal.enums.MembershipType` 437 The player's membership type, e,g. XBOX, STEAM, PSN 438 439 Returns 440 -------- 441 `collections.Sequence[aiobungie.crates.DestinyMembership]` 442 A sequence of the found Destiny 2 player memberships. 443 An empty sequence will be returned if no one found. 444 445 Raises 446 ------ 447 `aiobungie.MembershipTypeError` 448 The provided membership type was invalid. 449 """ 450 resp = await self.rest.fetch_membership(name, code, type) 451 452 return self._framework.deserialize_destiny_memberships(resp) 453 454 async def fetch_character( 455 self, 456 member_id: int, 457 membership_type: enums.MembershipType | int, 458 character_id: int, 459 components: collections.Sequence[enums.ComponentType], 460 auth: str | None = None, 461 ) -> components.CharacterComponent: 462 """Fetch a Destiny 2 character. 463 464 Example 465 ------- 466 ```py 467 membership_id, titan_id = 0, 0 468 my_character = await client.fetch_character( 469 membership_id, 470 MembershipType.STEAM, 471 titan_id, 472 components=(ComponentType.CHARACTER_INVENTORIES,) 473 ) 474 inventory = my_character.inventory 475 if inventory is not None: 476 for item in inventory.values(): 477 print(item) 478 ``` 479 480 Parameters 481 ---------- 482 member_id: `int` 483 A valid bungie member id. 484 character_id: `int` 485 The Destiny character id to retrieve. 486 membership_type: `aiobungie.internal.enums.MembershipType` 487 The member's membership type. 488 components: `collections.Sequence[aiobungie.ComponentType]` 489 Multiple arguments of character components to collect and return. 490 491 Other Parameters 492 ---------------- 493 auth : `str | None` 494 A Bearer access_token to make the request with. 495 This is optional and limited to components that only requires an Authorization token. 496 497 Returns 498 ------- 499 `aiobungie.crates.CharacterComponent` 500 A Bungie character component. 501 502 `aiobungie.MembershipTypeError` 503 The provided membership type was invalid. 504 """ 505 resp = await self.rest.fetch_character( 506 member_id, membership_type, character_id, components, auth 507 ) 508 509 return self._framework.deserialize_character_component(resp) 510 511 async def fetch_unique_weapon_history( 512 self, 513 membership_id: int, 514 character_id: int, 515 membership_type: enums.MembershipType | int, 516 ) -> collections.Sequence[activity.ExtendedWeaponValues]: 517 """Fetch details about unique weapon usage for a character. Includes all exotics. 518 519 Parameters 520 ---------- 521 membership_id : `int` 522 The Destiny user membership id. 523 character_id : `int` 524 The character id to retrieve. 525 membership_type : `aiobungie.aiobungie.MembershipType | int` 526 The Destiny user's membership type. 527 528 Returns 529 ------- 530 `collections.Sequence[aiobungie.crates.ExtendedWeaponValues]` 531 A sequence of the weapon's extended values. 532 """ 533 resp = await self._rest.fetch_unique_weapon_history( 534 membership_id, character_id, membership_type 535 ) 536 537 return tuple( 538 self._framework.deserialize_extended_weapon_values(weapon) 539 for weapon in resp["weapons"] 540 ) 541 542 # * Destiny 2 Activities. 543 544 async def fetch_activities( 545 self, 546 member_id: int, 547 character_id: int, 548 mode: enums.GameMode | int, 549 *, 550 membership_type: enums.MembershipType | int = enums.MembershipType.ALL, 551 page: int = 0, 552 limit: int = 250, 553 ) -> sain.Iterator[activity.Activity]: 554 """Fetch a Destiny 2 activity for the specified character id. 555 556 Parameters 557 ---------- 558 member_id: `int` 559 The user id that starts with `4611`. 560 character_id: `int` 561 The id of the character to retrieve the activities for. 562 mode: `aiobungie.aiobungie.internal.enums.GameMode | int` 563 This parameter filters the game mode, Nightfall, Strike, Iron Banner, etc. 564 565 Other Parameters 566 ---------------- 567 membership_type: `aiobungie.internal.enums.MembershipType` 568 The Member ship type, if nothing was passed than it will return all. 569 page: int 570 The page number. Default is `0` 571 limit: int 572 Limit the returned result. Default is `250`. 573 574 Returns 575 ------- 576 `Iterator[aiobungie.crates.Activity]` 577 An iterator of the player's activities. 578 579 Raises 580 ------ 581 `aiobungie.MembershipTypeError` 582 The provided membership type was invalid. 583 """ 584 resp = await self.rest.fetch_activities( 585 member_id, 586 character_id, 587 mode, 588 membership_type=membership_type, 589 page=page, 590 limit=limit, 591 ) 592 593 return self._framework.deserialize_activities(resp) 594 595 async def fetch_post_activity(self, instance_id: int, /) -> activity.PostActivity: 596 """Fetch a post activity details. 597 598 Parameters 599 ---------- 600 instance_id: `int` 601 The activity instance id. 602 603 Returns 604 ------- 605 `aiobungie.crates.PostActivity` 606 A post activity object. 607 """ 608 resp = await self.rest.fetch_post_activity(instance_id) 609 610 return self._framework.deserialize_post_activity(resp) 611 612 async def fetch_aggregated_activity_stats( 613 self, 614 character_id: int, 615 membership_id: int, 616 membership_type: enums.MembershipType | int, 617 ) -> sain.Iterator[activity.AggregatedActivity]: 618 """Fetch aggregated activity stats for a character. 619 620 Parameters 621 ---------- 622 character_id: `int` 623 The id of the character to retrieve the activities for. 624 membership_id: `int` 625 The id of the user that started with `4611`. 626 membership_type: `aiobungie.internal.enums.MembershipType` 627 The Member ship type. 628 629 Returns 630 ------- 631 `Iterator[aiobungie.crates.AggregatedActivity]` 632 An iterator of the player's activities. 633 634 Raises 635 ------ 636 `aiobungie.MembershipTypeError` 637 The provided membership type was invalid. 638 """ 639 resp = await self.rest.fetch_aggregated_activity_stats( 640 character_id, membership_id, membership_type 641 ) 642 643 return self._framework.deserialize_aggregated_activities(resp) 644 645 # * Destiny 2 Clans or GroupsV2. 646 647 async def fetch_clan_from_id( 648 self, 649 id: int, 650 /, 651 access_token: str | None = None, 652 ) -> clans.Clan: 653 """Fetch a Bungie Clan by its id. 654 655 Parameters 656 ----------- 657 id: `int` 658 The clan id. 659 660 Returns 661 -------- 662 `aiobungie.crates.Clan` 663 An Bungie clan. 664 665 Raises 666 ------ 667 `aiobungie.NotFound` 668 The clan was not found. 669 """ 670 resp = await self.rest.fetch_clan_from_id(id, access_token) 671 672 return self._framework.deserialize_clan(resp) 673 674 async def fetch_clan( 675 self, 676 name: str, 677 /, 678 access_token: str | None = None, 679 *, 680 type: enums.GroupType | int = enums.GroupType.CLAN, 681 ) -> clans.Clan: 682 """Fetch a Clan by its name. 683 This method will return the first clan found with given name. 684 685 Parameters 686 ---------- 687 name: `str` 688 The clan name 689 690 Other Parameters 691 ---------------- 692 access_token : `str | None` 693 An optional access token to make the request with. 694 695 If the token was bound to a member of the clan, 696 This field `aiobungie.crates.Clan.current_user_membership` will be available 697 and will return the membership of the user who made this request. 698 type : `aiobungie.GroupType` 699 The group type, Default is aiobungie.GroupType.CLAN. 700 701 Returns 702 ------- 703 `aiobungie.crates.Clan` 704 A Bungie clan. 705 706 Raises 707 ------ 708 `aiobungie.NotFound` 709 The clan was not found. 710 """ 711 resp = await self.rest.fetch_clan(name, access_token, type=type) 712 713 return self._framework.deserialize_clan(resp) 714 715 async def fetch_clan_conversations( 716 self, clan_id: int, / 717 ) -> collections.Sequence[clans.ClanConversation]: 718 """Fetch the conversations/chat channels of the given clan id. 719 720 Parameters 721 ---------- 722 clan_id : `int` 723 The clan id. 724 725 Returns 726 `collections.Sequence[aiobungie.crates.ClanConversation]` 727 A sequence of the clan chat channels. 728 """ 729 resp = await self.rest.fetch_clan_conversations(clan_id) 730 731 return self._framework.deserialize_clan_conversations(resp) 732 733 async def fetch_clan_admins( 734 self, clan_id: int, / 735 ) -> sain.Iterator[clans.ClanMember]: 736 """Fetch the clan founder and admins. 737 738 Parameters 739 ---------- 740 clan_id : `int` 741 The clan id. 742 743 Returns 744 ------- 745 `aiobungie.Iterator[aiobungie.crates.ClanMember]` 746 An iterator over the found clan admins and founder. 747 748 Raises 749 ------ 750 `aiobungie.NotFound` 751 The requested clan was not found. 752 """ 753 resp = await self.rest.fetch_clan_admins(clan_id) 754 755 return self._framework.deserialize_clan_members(resp) 756 757 async def fetch_groups_for_member( 758 self, 759 member_id: int, 760 member_type: enums.MembershipType | int, 761 /, 762 *, 763 filter: int = 0, 764 group_type: enums.GroupType = enums.GroupType.CLAN, 765 ) -> collections.Sequence[clans.GroupMember]: 766 """Fetch information about the groups that a given member has joined. 767 768 Parameters 769 ---------- 770 member_id : `int` 771 The member's id 772 member_type : `aiobungie.MembershipType` 773 The member's membership type. 774 775 Other Parameters 776 ---------------- 777 filter : `int` 778 Filter apply to list of joined groups. This Default to `0` 779 group_type : `aiobungie.GroupType` 780 The group's type. 781 This is always set to `aiobungie.GroupType.CLAN` and should not be changed. 782 783 Returns 784 ------- 785 `collections.Sequence[aiobungie.crates.GroupMember]` 786 A sequence of joined groups for the fetched member. 787 """ 788 resp = await self.rest.fetch_groups_for_member( 789 member_id, member_type, filter=filter, group_type=group_type 790 ) 791 792 return tuple( 793 self._framework.deserialize_group_member(group) for group in resp["results"] 794 ) 795 796 async def fetch_potential_groups_for_member( 797 self, 798 member_id: int, 799 member_type: enums.MembershipType | int, 800 /, 801 *, 802 filter: int = 0, 803 group_type: enums.GroupType | int = enums.GroupType.CLAN, 804 ) -> collections.Sequence[clans.GroupMember]: 805 """Fetch the potential groups for a clan member. 806 807 Parameters 808 ---------- 809 member_id : `int` 810 The member's id 811 member_type : `aiobungie.aiobungie.MembershipType | int` 812 The member's membership type. 813 814 Other Parameters 815 ---------------- 816 filter : `int` 817 Filter apply to list of joined groups. This Default to `0` 818 group_type : `aiobungie.aiobungie.GroupType | int` 819 The group's type. 820 This is always set to `aiobungie.GroupType.CLAN` and should not be changed. 821 822 Returns 823 ------- 824 `collections.Sequence[aiobungie.crates.GroupMember]` 825 A sequence of joined potential groups for the fetched member. 826 """ 827 resp = await self.rest.fetch_potential_groups_for_member( 828 member_id, member_type, filter=filter, group_type=group_type 829 ) 830 831 return tuple( 832 self._framework.deserialize_group_member(group) for group in resp["results"] 833 ) 834 835 async def fetch_clan_members( 836 self, 837 clan_id: int, 838 /, 839 *, 840 name: str | None = None, 841 type: enums.MembershipType | int = enums.MembershipType.NONE, 842 ) -> sain.Iterator[clans.ClanMember]: 843 """Fetch Bungie clan members. 844 845 Parameters 846 ---------- 847 clan_id : `int` 848 The clans id 849 850 Other Parameters 851 ---------------- 852 name : `str | None` 853 If provided, Only players matching this name will be returned. 854 type : `aiobungie.MembershipType` 855 An optional clan member's membership type. 856 This parameter is used to filter the returned results 857 by the provided membership, For an example XBox memberships only, 858 Otherwise will return all memberships. 859 860 Returns 861 ------- 862 `Iterator[aiobungie.crates.ClanMember]` 863 An iterator over the bungie clan members. 864 865 Raises 866 ------ 867 `aiobungie.NotFound` 868 The clan was not found. 869 """ 870 resp = await self.rest.fetch_clan_members(clan_id, type=type, name=name) 871 872 return self._framework.deserialize_clan_members(resp) 873 874 async def fetch_clan_banners(self) -> collections.Sequence[clans.ClanBanner]: 875 """Fetch the clan banners. 876 877 Returns 878 ------- 879 `collections.Sequence[aiobungie.crates.ClanBanner]` 880 A sequence of the clan banners. 881 """ 882 resp = await self.rest.fetch_clan_banners() 883 884 return self._framework.deserialize_clan_banners(resp) 885 886 # This method is required to be here since it deserialize the clan. 887 async def kick_clan_member( 888 self, 889 access_token: str, 890 /, 891 group_id: int, 892 membership_id: int, 893 membership_type: enums.MembershipType | int, 894 ) -> clans.Clan: 895 """Kick a member from the clan. 896 897 .. note:: 898 This request requires OAuth2: oauth2: `AdminGroups` scope. 899 900 Parameters 901 ---------- 902 access_token : `str` 903 The bearer access token associated with the bungie account. 904 group_id: `int` 905 The group id. 906 membership_id : `int` 907 The member id to kick. 908 membership_type : `aiobungie.aiobungie.MembershipType | int` 909 The member's membership type. 910 911 Returns 912 ------- 913 `aiobungie.crates.clan.Clan` 914 The clan that the member was kicked from. 915 """ 916 resp = await self.rest.kick_clan_member( 917 access_token, 918 group_id=group_id, 919 membership_id=membership_id, 920 membership_type=membership_type, 921 ) 922 923 return self._framework.deserialize_clan(resp) 924 925 async def fetch_clan_weekly_rewards(self, clan_id: int) -> milestones.Milestone: 926 """Fetch a Bungie clan's weekly reward state. 927 928 Parameters 929 ---------- 930 clan_id : `int` 931 The clan's id. 932 933 Returns 934 ------- 935 `aiobungie.crates.Milestone` 936 A runtime status of the clan's milestone data. 937 """ 938 939 resp = await self.rest.fetch_clan_weekly_rewards(clan_id) 940 941 return self._framework.deserialize_milestone(resp) 942 943 async def search_group( 944 self, 945 name: str, 946 group_type: enums.GroupType | int, 947 *, 948 creation_date: clans.GroupDate | int = 0, 949 sort_by: int | None = None, 950 group_member_count_filter: typing.Literal[0, 1, 2, 3] | None = None, 951 locale_filter: str | None = None, 952 tag_text: str | None = None, 953 items_per_page: int | None = None, 954 current_page: int | None = None, 955 request_token: str | None = None, 956 ) -> collections.Sequence[clans.Group]: 957 """Search for groups. 958 959 .. note:: 960 If the group type is set to `CLAN`, then parameters `group_member_count_filter`, 961 `locale_filter` and `tag_text` must be `None`, otherwise `ValueError` will be raised. 962 963 Parameters 964 ---------- 965 name : `str` 966 The group name. 967 group_type : `aiobungie.GroupType | int` 968 The group type that's being searched for. 969 970 Other Parameters 971 ---------------- 972 creation_date : `aiobungie.GroupDate | int` 973 The creation date of the group. Defaults to `0` which is all time. 974 sort_by : `int | None` 975 ... 976 group_member_count_filter : `int | None` 977 ... 978 locale_filter : `str | None` 979 ... 980 tag_text : `str | None` 981 ... 982 items_per_page : `int | None` 983 ... 984 current_page : `int | None` 985 ... 986 request_token : `str | None` 987 ... 988 989 Returns 990 -------- 991 `collections.Sequence[aiobungie.crates.Group]` 992 An array that contains the groups that match the search criteria. 993 994 Raises 995 ------ 996 `ValueError` 997 If the group type is `aiobungie.GroupType.CLAN` and `group_member_count_filter`, 998 `locale_filter` and `tag_text` are not `None`. 999 """ 1000 response = await self._rest.search_group( 1001 name, 1002 group_type, 1003 sort_by=sort_by, 1004 creation_date=creation_date, 1005 group_member_count_filter=group_member_count_filter, 1006 locale_filter=locale_filter, 1007 tag_text=tag_text, 1008 items_per_page=items_per_page, 1009 current_page=current_page, 1010 request_token=request_token, 1011 ) 1012 return tuple( 1013 self._framework.deserialize_group(result) for result in response["results"] 1014 ) 1015 1016 # * Destiny 2 Entities aka Definitions. 1017 1018 async def fetch_inventory_item(self, hash: int, /) -> entity.InventoryEntity: 1019 """Fetch a static inventory item entity given a its hash. 1020 1021 Parameters 1022 ---------- 1023 hash: `int` 1024 Inventory item's hash. 1025 1026 Returns 1027 ------- 1028 `aiobungie.crates.InventoryEntity` 1029 A bungie inventory item. 1030 """ 1031 resp = await self.rest.fetch_inventory_item(hash) 1032 1033 return self._framework.deserialize_inventory_entity(resp) 1034 1035 async def fetch_objective_entity(self, hash: int, /) -> entity.ObjectiveEntity: 1036 """Fetch a Destiny objective entity given a its hash. 1037 1038 Parameters 1039 ---------- 1040 hash: `int` 1041 objective's hash. 1042 1043 Returns 1044 ------- 1045 `aiobungie.crates.ObjectiveEntity` 1046 An objective entity item. 1047 """ 1048 resp = await self.rest.fetch_objective_entity(hash) 1049 1050 return self._framework.deserialize_objective_entity(resp) 1051 1052 @helpers.unstable 1053 async def search_entities( 1054 self, name: str, entity_type: str, *, page: int = 0 1055 ) -> sain.Iterator[entity.SearchableEntity]: 1056 """Search for Destiny2 entities given a name and its type. 1057 1058 Parameters 1059 ---------- 1060 name : `str` 1061 The name of the entity, i.e., Thunderlord, One thousand voices. 1062 entity_type : `str` 1063 The type of the entity, AKA Definition, 1064 For an example `DestinyInventoryItemDefinition` for emblems, weapons, and other inventory items. 1065 1066 Other Parameters 1067 ---------------- 1068 page : `int` 1069 An optional page to return. Default to 0. 1070 1071 Returns 1072 ------- 1073 `Iterator[aiobungie.crates.SearchableEntity]` 1074 An iterator over the found results matching the provided name. 1075 """ 1076 # resp = await self.rest.search_entities(name, entity_type, page=page) 1077 # calling this method will raise anyways. 1078 raise 1079 1080 # Fireteams 1081 1082 async def fetch_fireteams( 1083 self, 1084 activity_type: fireteams.FireteamActivity | int, 1085 *, 1086 platform: fireteams.FireteamPlatform | int = fireteams.FireteamPlatform.ANY, 1087 language: fireteams.FireteamLanguage | str = fireteams.FireteamLanguage.ALL, 1088 date_range: int = 0, 1089 page: int = 0, 1090 slots_filter: int = 0, 1091 ) -> collections.Sequence[fireteams.Fireteam]: 1092 """Fetch public Bungie fireteams with open slots. 1093 1094 Parameters 1095 ---------- 1096 activity_type : `aiobungie.aiobungie.crates.FireteamActivity | int` 1097 The fireteam activity type. 1098 1099 Other Parameters 1100 ---------------- 1101 platform : `aiobungie.aiobungie.crates.fireteams.FireteamPlatform | int` 1102 If this is provided. Then the results will be filtered with the given platform. 1103 Defaults to `aiobungie.crates.FireteamPlatform.ANY` which returns all platforms. 1104 language : `aiobungie.crates.fireteams.FireteamLanguage | str` 1105 A locale language to filter the used language in that fireteam. 1106 Defaults to `aiobungie.crates.FireteamLanguage.ALL` 1107 date_range : `int` 1108 An integer to filter the date range of the returned fireteams. Defaults to `aiobungie.FireteamDate.ALL`. 1109 page : `int` 1110 The page number. By default its `0` which returns all available activities. 1111 slots_filter : `int` 1112 Filter the returned fireteams based on available slots. Default is `0` 1113 1114 Returns 1115 ------- 1116 `collections.Sequence[fireteams.Fireteam]` 1117 A sequence of `aiobungie.crates.Fireteam`. 1118 """ 1119 1120 resp = await self.rest.fetch_fireteams( 1121 activity_type, 1122 platform=platform, 1123 language=language, 1124 date_range=date_range, 1125 page=page, 1126 slots_filter=slots_filter, 1127 ) 1128 1129 return self._framework.deserialize_fireteams(resp) 1130 1131 async def fetch_available_clan_fireteams( 1132 self, 1133 access_token: str, 1134 group_id: int, 1135 activity_type: fireteams.FireteamActivity | int, 1136 *, 1137 platform: fireteams.FireteamPlatform | int, 1138 language: fireteams.FireteamLanguage | str, 1139 date_range: int = 0, 1140 page: int = 0, 1141 public_only: bool = False, 1142 slots_filter: int = 0, 1143 ) -> collections.Sequence[fireteams.Fireteam]: 1144 """Fetch a clan's fireteams with open slots. 1145 1146 .. note:: 1147 This method requires OAuth2: ReadGroups scope. 1148 1149 Parameters 1150 ---------- 1151 access_token : `str` 1152 The bearer access token associated with the bungie account. 1153 group_id : `int` 1154 The group/clan id of the fireteam. 1155 activity_type : `aiobungie.aiobungie.crates.FireteamActivity | int` 1156 The fireteam activity type. 1157 1158 Other Parameters 1159 ---------------- 1160 platform : `aiobungie.aiobungie.crates.fireteams.FireteamPlatform | int` 1161 If this is provided. Then the results will be filtered with the given platform. 1162 Defaults to `aiobungie.crates.FireteamPlatform.ANY` which returns all platforms. 1163 language : `aiobungie.crates.fireteams.FireteamLanguage | str` 1164 A locale language to filter the used language in that fireteam. 1165 Defaults to `aiobungie.crates.FireteamLanguage.ALL` 1166 date_range : `int` 1167 An integer to filter the date range of the returned fireteams. Defaults to `0`. 1168 page : `int` 1169 The page number. By default its `0` which returns all available activities. 1170 public_only: `bool` 1171 If set to True, Then only public fireteams will be returned. 1172 slots_filter : `int` 1173 Filter the returned fireteams based on available slots. Default is `0` 1174 1175 Returns 1176 ------- 1177 `collections.Sequence[aiobungie.crates.Fireteam]` 1178 A sequence of fireteams found in the clan. 1179 `None` will be returned if nothing was found. 1180 """ 1181 resp = await self.rest.fetch_available_clan_fireteams( 1182 access_token, 1183 group_id, 1184 activity_type, 1185 platform=platform, 1186 language=language, 1187 date_range=date_range, 1188 page=page, 1189 public_only=public_only, 1190 slots_filter=slots_filter, 1191 ) 1192 1193 return self._framework.deserialize_fireteams(resp) 1194 1195 async def fetch_clan_fireteam( 1196 self, access_token: str, fireteam_id: int, group_id: int 1197 ) -> fireteams.AvailableFireteam: 1198 """Fetch a specific clan fireteam. 1199 1200 .. note:: 1201 This method requires OAuth2: ReadGroups scope. 1202 1203 Parameters 1204 ---------- 1205 access_token : `str` 1206 The bearer access token associated with the bungie account. 1207 group_id : `int` 1208 The group/clan id to fetch the fireteam from. 1209 fireteam_id : `int` 1210 The fireteam id to fetch. 1211 1212 Returns 1213 ------- 1214 `aiobungie.crates.AvailableFireteam` 1215 A sequence of available fireteams objects. 1216 """ 1217 resp = await self.rest.fetch_clan_fireteam(access_token, fireteam_id, group_id) 1218 1219 return self._framework.deserialize_available_fireteam(resp) 1220 1221 async def fetch_my_clan_fireteams( 1222 self, 1223 access_token: str, 1224 group_id: int, 1225 *, 1226 include_closed: bool = True, 1227 platform: fireteams.FireteamPlatform | int, 1228 language: fireteams.FireteamLanguage | str, 1229 filtered: bool = True, 1230 page: int = 0, 1231 ) -> collections.Sequence[fireteams.AvailableFireteam]: 1232 """A method that's similar to `fetch_fireteams` but requires OAuth2. 1233 1234 .. note:: 1235 This method requires OAuth2: ReadGroups scope. 1236 1237 Parameters 1238 ---------- 1239 access_token : str 1240 The bearer access token associated with the bungie account. 1241 group_id : int 1242 The group/clan id to fetch. 1243 1244 Other Parameters 1245 ---------------- 1246 include_closed : `bool` 1247 If provided and set to True, It will also return closed fireteams. 1248 If provided and set to False, It will only return public fireteams. Default is True. 1249 platform : aiobungie.aiobungie.crates.fireteams.FireteamPlatform | int 1250 If this is provided. Then the results will be filtered with the given platform. 1251 Defaults to aiobungie.crates.FireteamPlatform.ANY which returns all platforms. 1252 language : `aiobungie.crates.fireteams.FireteamLanguage | str` 1253 A locale language to filter the used language in that fireteam. 1254 Defaults to aiobungie.crates.FireteamLanguage.ALL 1255 filtered : `bool` 1256 If set to True, it will filter by clan. Otherwise not. Default is True. 1257 page : `int` 1258 The page number. By default its 0 which returns all available activities. 1259 1260 Returns 1261 ------- 1262 `collections.Sequence[aiobungie.crates.AvailableFireteam]` 1263 A sequence of available fireteams objects if exists. else `None` will be returned. 1264 """ 1265 resp = await self.rest.fetch_my_clan_fireteams( 1266 access_token, 1267 group_id, 1268 include_closed=include_closed, 1269 platform=platform, 1270 language=language, 1271 filtered=filtered, 1272 page=page, 1273 ) 1274 1275 return self._framework.deserialize_available_fireteams(resp) 1276 1277 # Friends and social. 1278 1279 async def fetch_friends( 1280 self, access_token: str, / 1281 ) -> collections.Sequence[friends.Friend]: 1282 """Fetch bungie friend list. 1283 1284 .. note:: 1285 This requests OAuth2: ReadUserData scope. 1286 1287 Parameters 1288 ----------- 1289 access_token : `str` 1290 The bearer access token associated with the bungie account. 1291 1292 Returns 1293 ------- 1294 `collections.Sequence[aiobungie.crates.Friend]` 1295 A sequence of the friends associated with that access token. 1296 """ 1297 1298 resp = await self.rest.fetch_friends(access_token) 1299 1300 return self._framework.deserialize_friends(resp) 1301 1302 async def fetch_friend_requests( 1303 self, access_token: str, / 1304 ) -> friends.FriendRequestView: 1305 """Fetch pending bungie friend requests queue. 1306 1307 .. note:: 1308 This requests OAuth2: ReadUserData scope. 1309 1310 Parameters 1311 ----------- 1312 access_token : `str` 1313 The bearer access token associated with the bungie account. 1314 1315 Returns 1316 ------- 1317 `aiobungie.crates.FriendRequestView` 1318 A friend requests view of that associated access token. 1319 """ 1320 1321 resp = await self.rest.fetch_friend_requests(access_token) 1322 1323 return self._framework.deserialize_friend_requests(resp) 1324 1325 # Applications and Developer portal. 1326 1327 async def fetch_application(self, appid: int, /) -> application.Application: 1328 """Fetch a Bungie application. 1329 1330 Parameters 1331 ----------- 1332 appid: `int` 1333 The application id. 1334 1335 Returns 1336 -------- 1337 `aiobungie.crates.Application` 1338 A Bungie application. 1339 """ 1340 resp = await self.rest.fetch_application(appid) 1341 1342 return self._framework.deserialize_application(resp) 1343 1344 # Milestones 1345 1346 async def fetch_public_milestone_content( 1347 self, milestone_hash: int, / 1348 ) -> milestones.MilestoneContent: 1349 """Fetch the milestone content given its hash. 1350 1351 Parameters 1352 ---------- 1353 milestone_hash : `int` 1354 The milestone hash. 1355 1356 Returns 1357 ------- 1358 `aiobungie.crates.milestones.MilestoneContent` 1359 A milestone content object. 1360 """ 1361 ... 1362 resp = await self.rest.fetch_public_milestone_content(milestone_hash) 1363 return self._framework.deserialize_public_milestone_content(resp)
Compact standard client implementation.
This client is the way to be able to start sending requests over the REST API and receiving deserialized response objects.
Refer to aiobungie.RESTClient
if you prefer to use a more lower-level client.
Example
import aiobungie
import asyncio
async def main():
client = aiobungie.Client('token')
async with client.rest:
user = await client.fetch_bungie_user(20315338)
print(user)
asyncio.run(main())
Parameters
- token (
str
): Your Bungie's API key or Token from the developer's portal.
Other Parameters
- client_secret (
str | None
): An optional application client secret, This is only needed if you're fetching OAuth2 tokens with this client. - client_id (
int | None
): An optional application client id, This is only needed if you're fetching OAuth2 tokens with this client. - settings (
aiobungie.builders.Settings | None
): The client settings to use, ifNone
the default will be used. - max_retries (
int
): The max retries number to retry if the request hit a5xx
status code. - debug (
"TRACE" | bool | int
): The level of logging to enable.
101 def __init__( 102 self, 103 token: str, 104 /, 105 *, 106 client_secret: str | None = None, 107 client_id: int | None = None, 108 settings: builders.Settings | None = None, 109 max_retries: int = 4, 110 debug: typing.Literal["TRACE"] | bool | int = False, 111 ) -> None: 112 self._rest = rest_.RESTClient( 113 token, 114 client_secret=client_secret, 115 client_id=client_id, 116 settings=settings, 117 max_retries=max_retries, 118 debug=debug, 119 ) 120 121 self._framework = framework.Framework()
An implementation of a aiobungie.api.Framework
object used by your client.
131 @property 132 def metadata(self) -> collections.MutableMapping[typing.Any, typing.Any]: 133 return self._rest.metadata
A mutable mapping storage for the user's needs.
141 async def fetch_current_user_memberships(self, access_token: str, /) -> user.User: 142 """Fetch and return a user object of the bungie net user associated with account. 143 144 .. warning:: 145 This method requires OAuth2 scope and a Bearer access token. 146 147 Parameters 148 ---------- 149 access_token : `str` 150 A valid Bearer access token for the authorization. 151 152 Returns 153 ------- 154 `aiobungie.crates.user.User` 155 A user object includes the Destiny memberships and Bungie.net user. 156 """ 157 resp = await self.rest.fetch_current_user_memberships(access_token) 158 159 return self._framework.deserialize_user(resp)
Fetch and return a user object of the bungie net user associated with account.
This method requires OAuth2 scope and a Bearer access token.
Parameters
- access_token (
str
): A valid Bearer access token for the authorization.
Returns
aiobungie.crates.user.User
: A user object includes the Destiny memberships and Bungie.net user.
161 async def fetch_bungie_user(self, id: int, /) -> user.BungieUser: 162 """Fetch a Bungie user by their BungieNet id. 163 164 Parameters 165 ---------- 166 id: `int` 167 The user id. 168 169 Returns 170 ------- 171 `aiobungie.crates.user.BungieUser` 172 A Bungie user. 173 174 Raises 175 ------ 176 `aiobungie.error.NotFound` 177 The user was not found. 178 """ 179 payload = await self.rest.fetch_bungie_user(id) 180 return self._framework.deserialize_bungie_user(payload)
Fetch a Bungie user by their BungieNet id.
Parameters
- id (
int
): The user id.
Returns
aiobungie.crates.user.BungieUser
: A Bungie user.
Raises
aiobungie.error.NotFound
: The user was not found.
182 async def search_users( 183 self, name: str, / 184 ) -> sain.Iterator[user.SearchableDestinyUser]: 185 """Search for players and return all players that matches the same name. 186 187 Parameters 188 ---------- 189 name : `str` 190 The user name. 191 192 Returns 193 ------- 194 `aiobungie.Iterator[aiobungie.crates.SearchableDestinyUser]` 195 A sequence of the found users with this name. 196 """ 197 payload = await self.rest.search_users(name) 198 return sain.Iter( 199 self._framework.deserialize_searched_user(user) 200 for user in payload["searchResults"] 201 )
Search for players and return all players that matches the same name.
Parameters
- name (
str
): The user name.
Returns
aiobungie.Iterator[aiobungie.crates.SearchableDestinyUser]
: A sequence of the found users with this name.
203 async def fetch_user_themes(self) -> collections.Sequence[user.UserThemes]: 204 """Fetch all available user themes. 205 206 Returns 207 ------- 208 `collections.Sequence[aiobungie.crates.user.UserThemes]` 209 A sequence of user themes. 210 """ 211 data = await self.rest.fetch_user_themes() 212 213 return self._framework.deserialize_user_themes(data)
Fetch all available user themes.
Returns
collections.Sequence[aiobungie.crates.user.UserThemes]
: A sequence of user themes.
215 async def fetch_hard_types( 216 self, 217 credential: int, 218 type: enums.CredentialType | int = enums.CredentialType.STEAMID, 219 /, 220 ) -> user.HardLinkedMembership: 221 """Gets any hard linked membership given a credential. 222 223 Only works for credentials that are public just `aiobungie.CredentialType.STEAMID` right now. 224 Cross Save aware. 225 226 Parameters 227 ---------- 228 credential: `int` 229 A valid SteamID64 230 type: `aiobungie.CredentialType` 231 The credential type. This must not be changed 232 Since its only credential that works "currently" 233 234 Returns 235 ------- 236 `aiobungie.crates.user.HardLinkedMembership` 237 Information about the hard linked data. 238 """ 239 240 payload = await self.rest.fetch_hardlinked_credentials(credential, type) 241 242 return user.HardLinkedMembership( 243 id=int(payload["membershipId"]), 244 type=enums.MembershipType(payload["membershipType"]), 245 cross_save_type=enums.MembershipType(payload["CrossSaveOverriddenType"]), 246 )
Gets any hard linked membership given a credential.
Only works for credentials that are public just aiobungie.CredentialType.STEAMID
right now.
Cross Save aware.
Parameters
- credential (
int
): A valid SteamID64 - type (
aiobungie.CredentialType
): The credential type. This must not be changed Since its only credential that works "currently"
Returns
aiobungie.crates.user.HardLinkedMembership
: Information about the hard linked data.
248 async def fetch_membership_from_id( 249 self, 250 id: int, 251 /, 252 type: enums.MembershipType | int = enums.MembershipType.NONE, 253 ) -> user.User: 254 """Fetch a Bungie user's memberships from their Bungie ID. 255 256 This method returns both Bungie user and its Destiny 2 memberships bound to it. 257 258 Parameters 259 ---------- 260 id : `int` 261 A Bungie.net user's ID. It looks something like this `20315338` 262 type : `aiobungie.MembershipType` 263 The user's membership type. This is optional. 264 265 Returns 266 ------- 267 `aiobungie.crates.User` 268 A Bungie user with their membership types. 269 270 Raises 271 ------ 272 `aiobungie.NotFound` 273 The requested user was not found. 274 """ 275 payload = await self.rest.fetch_membership_from_id(id, type) 276 277 return self._framework.deserialize_user(payload)
Fetch a Bungie user's memberships from their Bungie ID.
This method returns both Bungie user and its Destiny 2 memberships bound to it.
Parameters
- id (
int
): A Bungie.net user's ID. It looks something like this20315338
- type (
aiobungie.MembershipType
): The user's membership type. This is optional.
Returns
aiobungie.crates.User
: A Bungie user with their membership types.
Raises
aiobungie.NotFound
: The requested user was not found.
279 async def fetch_user_credentials( 280 self, access_token: str, membership_id: int, / 281 ) -> collections.Sequence[user.UserCredentials]: 282 """Fetch an array of credential types attached to the requested account. 283 284 .. note:: 285 This method require OAuth2 Bearer access token. 286 287 Parameters 288 ---------- 289 access_token : `str` 290 The bearer access token associated with the bungie account. 291 membership_id : `int` 292 The id of the membership to return. 293 294 Returns 295 ------- 296 `collections.Sequence[aiobungie.crates.UserCredentials]` 297 A sequence of the attached user credentials. 298 299 Raises 300 ------ 301 `aiobungie.Unauthorized` 302 The access token was wrong or no access token passed. 303 """ 304 resp = await self.rest.fetch_user_credentials(access_token, membership_id) 305 306 return self._framework.deserialize_user_credentials(resp)
Fetch an array of credential types attached to the requested account.
This method require OAuth2 Bearer access token.
Parameters
- access_token (
str
): The bearer access token associated with the bungie account. - membership_id (
int
): The id of the membership to return.
Returns
collections.Sequence[aiobungie.crates.UserCredentials]
: A sequence of the attached user credentials.
Raises
aiobungie.Unauthorized
: The access token was wrong or no access token passed.
308 async def fetch_sanitized_membership( 309 self, membership_id: int, / 310 ) -> user.SanitizedMembership: 311 """Fetch a list of all display names linked to `membership_id`, Which is profanity filtered. 312 313 Parameters 314 ---------- 315 membership_id: `int` 316 The membership ID to fetch 317 318 Returns 319 ------- 320 `aiobungie.crates.SanitizedMembership` 321 A JSON object contains all the available display names. 322 """ 323 response = await self._rest.fetch_sanitized_membership(membership_id) 324 return self._framework.deserialize_sanitized_membership(response)
Fetch a list of all display names linked to membership_id
, Which is profanity filtered.
Parameters
- membership_id (
int
): The membership ID to fetch
Returns
aiobungie.crates.SanitizedMembership
: A JSON object contains all the available display names.
328 async def fetch_profile( 329 self, 330 member_id: int, 331 type: enums.MembershipType | int, 332 components: collections.Sequence[enums.ComponentType], 333 auth: str | None = None, 334 ) -> components.Component: 335 """Fetch a Bungie profile with the required components. 336 337 Example 338 ------- 339 ```py 340 my_profile_id = 4611686018484639825 341 my_profile = await client.fetch_profile( 342 my_profile_id, 343 MembershipType.STEAM, 344 components=(ComponentType.CHARACTERS,) 345 ) 346 characters = my_profile.characters 347 if characters is not None: 348 for character in characters.values(): 349 print(character.power_level) 350 ``` 351 352 Parameters 353 ---------- 354 member_id: `int` 355 The profile membership's id. 356 type: `aiobungie.MembershipType` 357 The profile's membership type. 358 components : `collections.Sequence[aiobungie.ComponentType]` 359 A sequence of components to collect. If the sequence is empty, then all components will be `None`. 360 361 Other Parameters 362 ---------------- 363 auth : `str | None` 364 A Bearer access_token to make the request with. 365 This is optional and limited to components that only requires an Authorization token. 366 367 Returns 368 -------- 369 `aiobungie.crates.Component` 370 A Destiny 2 player profile with its components. 371 Only passed components will be available if they exists. Otherwise they will be `None` 372 373 Raises 374 ------ 375 `aiobungie.MembershipTypeError` 376 The provided membership type was invalid. 377 """ 378 data = await self.rest.fetch_profile(member_id, type, components, auth) 379 return self._framework.deserialize_components(data)
Fetch a Bungie profile with the required components.
Example
my_profile_id = 4611686018484639825
my_profile = await client.fetch_profile(
my_profile_id,
MembershipType.STEAM,
components=(ComponentType.CHARACTERS,)
)
characters = my_profile.characters
if characters is not None:
for character in characters.values():
print(character.power_level)
Parameters
- member_id (
int
): The profile membership's id. - type (
aiobungie.MembershipType
): The profile's membership type. - components (
collections.Sequence[aiobungie.ComponentType]
): A sequence of components to collect. If the sequence is empty, then all components will beNone
.
Other Parameters
- auth (
str | None
): A Bearer access_token to make the request with. This is optional and limited to components that only requires an Authorization token.
Returns
aiobungie.crates.Component
: A Destiny 2 player profile with its components. Only passed components will be available if they exists. Otherwise they will beNone
Raises
aiobungie.MembershipTypeError
: The provided membership type was invalid.
381 async def fetch_linked_profiles( 382 self, 383 member_id: int, 384 member_type: enums.MembershipType | int, 385 /, 386 *, 387 all: bool = False, 388 ) -> profile.LinkedProfile: 389 """Returns a summary information about all profiles linked to the requested member. 390 391 The passed membership id/type maybe a Bungie.Net membership or a Destiny memberships. 392 393 .. note:: 394 It will only return linked accounts whose linkages you are allowed to view. 395 396 Parameters 397 ---------- 398 member_id : `int` 399 The ID of the membership. This must be a valid Bungie.Net or PSN or Xbox ID. 400 member_type : `aiobungie.MembershipType` 401 The type for the membership whose linked Destiny account you want to return. 402 403 Other Parameters 404 ---------------- 405 all : `bool` 406 If provided and set to `True`, All memberships regardless 407 of whether they're obscured by overrides will be returned, 408 409 If provided and set to `False`, Only available memberships will be returned. 410 The default for this is `False`. 411 412 Returns 413 ------- 414 `aiobungie.crates.profile.LinkedProfile` 415 A linked profile object. 416 """ 417 resp = await self.rest.fetch_linked_profiles(member_id, member_type, all=all) 418 419 return self._framework.deserialize_linked_profiles(resp)
Returns a summary information about all profiles linked to the requested member.
The passed membership id/type maybe a Bungie.Net membership or a Destiny memberships.
It will only return linked accounts whose linkages you are allowed to view.
Parameters
- member_id (
int
): The ID of the membership. This must be a valid Bungie.Net or PSN or Xbox ID. - member_type (
aiobungie.MembershipType
): The type for the membership whose linked Destiny account you want to return.
Other Parameters
all (
bool
): If provided and set toTrue
, All memberships regardless of whether they're obscured by overrides will be returned,If provided and set to
False
, Only available memberships will be returned. The default for this isFalse
.
Returns
aiobungie.crates.profile.LinkedProfile
: A linked profile object.
421 async def fetch_membership( 422 self, 423 name: str, 424 code: int, 425 /, 426 type: enums.MembershipType | int = enums.MembershipType.ALL, 427 ) -> collections.Sequence[user.DestinyMembership]: 428 """Fetch a Destiny 2 player's memberships. 429 430 Parameters 431 ----------- 432 name: `str` 433 The unique Bungie player name. 434 code : `int` 435 The unique Bungie display name code. 436 type: `aiobungie.internal.enums.MembershipType` 437 The player's membership type, e,g. XBOX, STEAM, PSN 438 439 Returns 440 -------- 441 `collections.Sequence[aiobungie.crates.DestinyMembership]` 442 A sequence of the found Destiny 2 player memberships. 443 An empty sequence will be returned if no one found. 444 445 Raises 446 ------ 447 `aiobungie.MembershipTypeError` 448 The provided membership type was invalid. 449 """ 450 resp = await self.rest.fetch_membership(name, code, type) 451 452 return self._framework.deserialize_destiny_memberships(resp)
Fetch a Destiny 2 player's memberships.
Parameters
- name (
str
): The unique Bungie player name. - code (
int
): The unique Bungie display name code. - type (
aiobungie.internal.enums.MembershipType
): The player's membership type, e,g. XBOX, STEAM, PSN
Returns
collections.Sequence[aiobungie.crates.DestinyMembership]
: A sequence of the found Destiny 2 player memberships. An empty sequence will be returned if no one found.
Raises
aiobungie.MembershipTypeError
: The provided membership type was invalid.
454 async def fetch_character( 455 self, 456 member_id: int, 457 membership_type: enums.MembershipType | int, 458 character_id: int, 459 components: collections.Sequence[enums.ComponentType], 460 auth: str | None = None, 461 ) -> components.CharacterComponent: 462 """Fetch a Destiny 2 character. 463 464 Example 465 ------- 466 ```py 467 membership_id, titan_id = 0, 0 468 my_character = await client.fetch_character( 469 membership_id, 470 MembershipType.STEAM, 471 titan_id, 472 components=(ComponentType.CHARACTER_INVENTORIES,) 473 ) 474 inventory = my_character.inventory 475 if inventory is not None: 476 for item in inventory.values(): 477 print(item) 478 ``` 479 480 Parameters 481 ---------- 482 member_id: `int` 483 A valid bungie member id. 484 character_id: `int` 485 The Destiny character id to retrieve. 486 membership_type: `aiobungie.internal.enums.MembershipType` 487 The member's membership type. 488 components: `collections.Sequence[aiobungie.ComponentType]` 489 Multiple arguments of character components to collect and return. 490 491 Other Parameters 492 ---------------- 493 auth : `str | None` 494 A Bearer access_token to make the request with. 495 This is optional and limited to components that only requires an Authorization token. 496 497 Returns 498 ------- 499 `aiobungie.crates.CharacterComponent` 500 A Bungie character component. 501 502 `aiobungie.MembershipTypeError` 503 The provided membership type was invalid. 504 """ 505 resp = await self.rest.fetch_character( 506 member_id, membership_type, character_id, components, auth 507 ) 508 509 return self._framework.deserialize_character_component(resp)
Fetch a Destiny 2 character.
Example
membership_id, titan_id = 0, 0
my_character = await client.fetch_character(
membership_id,
MembershipType.STEAM,
titan_id,
components=(ComponentType.CHARACTER_INVENTORIES,)
)
inventory = my_character.inventory
if inventory is not None:
for item in inventory.values():
print(item)
Parameters
- member_id (
int
): A valid bungie member id. - character_id (
int
): The Destiny character id to retrieve. - membership_type (
aiobungie.internal.enums.MembershipType
): The member's membership type. - components (
collections.Sequence[aiobungie.ComponentType]
): Multiple arguments of character components to collect and return.
Other Parameters
- auth (
str | None
): A Bearer access_token to make the request with. This is optional and limited to components that only requires an Authorization token.
Returns
aiobungie.crates.CharacterComponent
: A Bungie character component.aiobungie.MembershipTypeError
: The provided membership type was invalid.
511 async def fetch_unique_weapon_history( 512 self, 513 membership_id: int, 514 character_id: int, 515 membership_type: enums.MembershipType | int, 516 ) -> collections.Sequence[activity.ExtendedWeaponValues]: 517 """Fetch details about unique weapon usage for a character. Includes all exotics. 518 519 Parameters 520 ---------- 521 membership_id : `int` 522 The Destiny user membership id. 523 character_id : `int` 524 The character id to retrieve. 525 membership_type : `aiobungie.aiobungie.MembershipType | int` 526 The Destiny user's membership type. 527 528 Returns 529 ------- 530 `collections.Sequence[aiobungie.crates.ExtendedWeaponValues]` 531 A sequence of the weapon's extended values. 532 """ 533 resp = await self._rest.fetch_unique_weapon_history( 534 membership_id, character_id, membership_type 535 ) 536 537 return tuple( 538 self._framework.deserialize_extended_weapon_values(weapon) 539 for weapon in resp["weapons"] 540 )
Fetch details about unique weapon usage for a character. Includes all exotics.
Parameters
- membership_id (
int
): The Destiny user membership id. - character_id (
int
): The character id to retrieve. - membership_type (
aiobungie.aiobungie.MembershipType | int
): The Destiny user's membership type.
Returns
collections.Sequence[aiobungie.crates.ExtendedWeaponValues]
: A sequence of the weapon's extended values.
544 async def fetch_activities( 545 self, 546 member_id: int, 547 character_id: int, 548 mode: enums.GameMode | int, 549 *, 550 membership_type: enums.MembershipType | int = enums.MembershipType.ALL, 551 page: int = 0, 552 limit: int = 250, 553 ) -> sain.Iterator[activity.Activity]: 554 """Fetch a Destiny 2 activity for the specified character id. 555 556 Parameters 557 ---------- 558 member_id: `int` 559 The user id that starts with `4611`. 560 character_id: `int` 561 The id of the character to retrieve the activities for. 562 mode: `aiobungie.aiobungie.internal.enums.GameMode | int` 563 This parameter filters the game mode, Nightfall, Strike, Iron Banner, etc. 564 565 Other Parameters 566 ---------------- 567 membership_type: `aiobungie.internal.enums.MembershipType` 568 The Member ship type, if nothing was passed than it will return all. 569 page: int 570 The page number. Default is `0` 571 limit: int 572 Limit the returned result. Default is `250`. 573 574 Returns 575 ------- 576 `Iterator[aiobungie.crates.Activity]` 577 An iterator of the player's activities. 578 579 Raises 580 ------ 581 `aiobungie.MembershipTypeError` 582 The provided membership type was invalid. 583 """ 584 resp = await self.rest.fetch_activities( 585 member_id, 586 character_id, 587 mode, 588 membership_type=membership_type, 589 page=page, 590 limit=limit, 591 ) 592 593 return self._framework.deserialize_activities(resp)
Fetch a Destiny 2 activity for the specified character id.
Parameters
- member_id (
int
): The user id that starts with4611
. - character_id (
int
): The id of the character to retrieve the activities for. - mode (
aiobungie.aiobungie.internal.enums.GameMode | int
): This parameter filters the game mode, Nightfall, Strike, Iron Banner, etc.
Other Parameters
- membership_type (
aiobungie.internal.enums.MembershipType
): The Member ship type, if nothing was passed than it will return all. - page (int):
The page number. Default is
0
- limit (int):
Limit the returned result. Default is
250
.
Returns
Iterator[aiobungie.crates.Activity]
: An iterator of the player's activities.
Raises
aiobungie.MembershipTypeError
: The provided membership type was invalid.
595 async def fetch_post_activity(self, instance_id: int, /) -> activity.PostActivity: 596 """Fetch a post activity details. 597 598 Parameters 599 ---------- 600 instance_id: `int` 601 The activity instance id. 602 603 Returns 604 ------- 605 `aiobungie.crates.PostActivity` 606 A post activity object. 607 """ 608 resp = await self.rest.fetch_post_activity(instance_id) 609 610 return self._framework.deserialize_post_activity(resp)
Fetch a post activity details.
Parameters
- instance_id (
int
): The activity instance id.
Returns
aiobungie.crates.PostActivity
: A post activity object.
612 async def fetch_aggregated_activity_stats( 613 self, 614 character_id: int, 615 membership_id: int, 616 membership_type: enums.MembershipType | int, 617 ) -> sain.Iterator[activity.AggregatedActivity]: 618 """Fetch aggregated activity stats for a character. 619 620 Parameters 621 ---------- 622 character_id: `int` 623 The id of the character to retrieve the activities for. 624 membership_id: `int` 625 The id of the user that started with `4611`. 626 membership_type: `aiobungie.internal.enums.MembershipType` 627 The Member ship type. 628 629 Returns 630 ------- 631 `Iterator[aiobungie.crates.AggregatedActivity]` 632 An iterator of the player's activities. 633 634 Raises 635 ------ 636 `aiobungie.MembershipTypeError` 637 The provided membership type was invalid. 638 """ 639 resp = await self.rest.fetch_aggregated_activity_stats( 640 character_id, membership_id, membership_type 641 ) 642 643 return self._framework.deserialize_aggregated_activities(resp)
Fetch aggregated activity stats for a character.
Parameters
- character_id (
int
): The id of the character to retrieve the activities for. - membership_id (
int
): The id of the user that started with4611
. - membership_type (
aiobungie.internal.enums.MembershipType
): The Member ship type.
Returns
Iterator[aiobungie.crates.AggregatedActivity]
: An iterator of the player's activities.
Raises
aiobungie.MembershipTypeError
: The provided membership type was invalid.
647 async def fetch_clan_from_id( 648 self, 649 id: int, 650 /, 651 access_token: str | None = None, 652 ) -> clans.Clan: 653 """Fetch a Bungie Clan by its id. 654 655 Parameters 656 ----------- 657 id: `int` 658 The clan id. 659 660 Returns 661 -------- 662 `aiobungie.crates.Clan` 663 An Bungie clan. 664 665 Raises 666 ------ 667 `aiobungie.NotFound` 668 The clan was not found. 669 """ 670 resp = await self.rest.fetch_clan_from_id(id, access_token) 671 672 return self._framework.deserialize_clan(resp)
Fetch a Bungie Clan by its id.
Parameters
- id (
int
): The clan id.
Returns
aiobungie.crates.Clan
: An Bungie clan.
Raises
aiobungie.NotFound
: The clan was not found.
674 async def fetch_clan( 675 self, 676 name: str, 677 /, 678 access_token: str | None = None, 679 *, 680 type: enums.GroupType | int = enums.GroupType.CLAN, 681 ) -> clans.Clan: 682 """Fetch a Clan by its name. 683 This method will return the first clan found with given name. 684 685 Parameters 686 ---------- 687 name: `str` 688 The clan name 689 690 Other Parameters 691 ---------------- 692 access_token : `str | None` 693 An optional access token to make the request with. 694 695 If the token was bound to a member of the clan, 696 This field `aiobungie.crates.Clan.current_user_membership` will be available 697 and will return the membership of the user who made this request. 698 type : `aiobungie.GroupType` 699 The group type, Default is aiobungie.GroupType.CLAN. 700 701 Returns 702 ------- 703 `aiobungie.crates.Clan` 704 A Bungie clan. 705 706 Raises 707 ------ 708 `aiobungie.NotFound` 709 The clan was not found. 710 """ 711 resp = await self.rest.fetch_clan(name, access_token, type=type) 712 713 return self._framework.deserialize_clan(resp)
Fetch a Clan by its name. This method will return the first clan found with given name.
Parameters
- name (
str
): The clan name
Other Parameters
access_token (
str | None
): An optional access token to make the request with.If the token was bound to a member of the clan, This field
aiobungie.crates.Clan.current_user_membership
will be available and will return the membership of the user who made this request.- type (
aiobungie.GroupType
): The group type, Default is aiobungie.GroupType.CLAN.
Returns
aiobungie.crates.Clan
: A Bungie clan.
Raises
aiobungie.NotFound
: The clan was not found.
715 async def fetch_clan_conversations( 716 self, clan_id: int, / 717 ) -> collections.Sequence[clans.ClanConversation]: 718 """Fetch the conversations/chat channels of the given clan id. 719 720 Parameters 721 ---------- 722 clan_id : `int` 723 The clan id. 724 725 Returns 726 `collections.Sequence[aiobungie.crates.ClanConversation]` 727 A sequence of the clan chat channels. 728 """ 729 resp = await self.rest.fetch_clan_conversations(clan_id) 730 731 return self._framework.deserialize_clan_conversations(resp)
Fetch the conversations/chat channels of the given clan id.
Parameters
- clan_id (
int
): The clan id. - Returns
collections.Sequence[aiobungie.crates.ClanConversation]
: A sequence of the clan chat channels.
733 async def fetch_clan_admins( 734 self, clan_id: int, / 735 ) -> sain.Iterator[clans.ClanMember]: 736 """Fetch the clan founder and admins. 737 738 Parameters 739 ---------- 740 clan_id : `int` 741 The clan id. 742 743 Returns 744 ------- 745 `aiobungie.Iterator[aiobungie.crates.ClanMember]` 746 An iterator over the found clan admins and founder. 747 748 Raises 749 ------ 750 `aiobungie.NotFound` 751 The requested clan was not found. 752 """ 753 resp = await self.rest.fetch_clan_admins(clan_id) 754 755 return self._framework.deserialize_clan_members(resp)
Fetch the clan founder and admins.
Parameters
- clan_id (
int
): The clan id.
Returns
aiobungie.Iterator[aiobungie.crates.ClanMember]
: An iterator over the found clan admins and founder.
Raises
aiobungie.NotFound
: The requested clan was not found.
757 async def fetch_groups_for_member( 758 self, 759 member_id: int, 760 member_type: enums.MembershipType | int, 761 /, 762 *, 763 filter: int = 0, 764 group_type: enums.GroupType = enums.GroupType.CLAN, 765 ) -> collections.Sequence[clans.GroupMember]: 766 """Fetch information about the groups that a given member has joined. 767 768 Parameters 769 ---------- 770 member_id : `int` 771 The member's id 772 member_type : `aiobungie.MembershipType` 773 The member's membership type. 774 775 Other Parameters 776 ---------------- 777 filter : `int` 778 Filter apply to list of joined groups. This Default to `0` 779 group_type : `aiobungie.GroupType` 780 The group's type. 781 This is always set to `aiobungie.GroupType.CLAN` and should not be changed. 782 783 Returns 784 ------- 785 `collections.Sequence[aiobungie.crates.GroupMember]` 786 A sequence of joined groups for the fetched member. 787 """ 788 resp = await self.rest.fetch_groups_for_member( 789 member_id, member_type, filter=filter, group_type=group_type 790 ) 791 792 return tuple( 793 self._framework.deserialize_group_member(group) for group in resp["results"] 794 )
Fetch information about the groups that a given member has joined.
Parameters
- member_id (
int
): The member's id - member_type (
aiobungie.MembershipType
): The member's membership type.
Other Parameters
- filter (
int
): Filter apply to list of joined groups. This Default to0
- group_type (
aiobungie.GroupType
): The group's type. This is always set toaiobungie.GroupType.CLAN
and should not be changed.
Returns
collections.Sequence[aiobungie.crates.GroupMember]
: A sequence of joined groups for the fetched member.
796 async def fetch_potential_groups_for_member( 797 self, 798 member_id: int, 799 member_type: enums.MembershipType | int, 800 /, 801 *, 802 filter: int = 0, 803 group_type: enums.GroupType | int = enums.GroupType.CLAN, 804 ) -> collections.Sequence[clans.GroupMember]: 805 """Fetch the potential groups for a clan member. 806 807 Parameters 808 ---------- 809 member_id : `int` 810 The member's id 811 member_type : `aiobungie.aiobungie.MembershipType | int` 812 The member's membership type. 813 814 Other Parameters 815 ---------------- 816 filter : `int` 817 Filter apply to list of joined groups. This Default to `0` 818 group_type : `aiobungie.aiobungie.GroupType | int` 819 The group's type. 820 This is always set to `aiobungie.GroupType.CLAN` and should not be changed. 821 822 Returns 823 ------- 824 `collections.Sequence[aiobungie.crates.GroupMember]` 825 A sequence of joined potential groups for the fetched member. 826 """ 827 resp = await self.rest.fetch_potential_groups_for_member( 828 member_id, member_type, filter=filter, group_type=group_type 829 ) 830 831 return tuple( 832 self._framework.deserialize_group_member(group) for group in resp["results"] 833 )
Fetch the potential groups for a clan member.
Parameters
- member_id (
int
): The member's id - member_type (
aiobungie.aiobungie.MembershipType | int
): The member's membership type.
Other Parameters
- filter (
int
): Filter apply to list of joined groups. This Default to0
- group_type (
aiobungie.aiobungie.GroupType | int
): The group's type. This is always set toaiobungie.GroupType.CLAN
and should not be changed.
Returns
collections.Sequence[aiobungie.crates.GroupMember]
: A sequence of joined potential groups for the fetched member.
835 async def fetch_clan_members( 836 self, 837 clan_id: int, 838 /, 839 *, 840 name: str | None = None, 841 type: enums.MembershipType | int = enums.MembershipType.NONE, 842 ) -> sain.Iterator[clans.ClanMember]: 843 """Fetch Bungie clan members. 844 845 Parameters 846 ---------- 847 clan_id : `int` 848 The clans id 849 850 Other Parameters 851 ---------------- 852 name : `str | None` 853 If provided, Only players matching this name will be returned. 854 type : `aiobungie.MembershipType` 855 An optional clan member's membership type. 856 This parameter is used to filter the returned results 857 by the provided membership, For an example XBox memberships only, 858 Otherwise will return all memberships. 859 860 Returns 861 ------- 862 `Iterator[aiobungie.crates.ClanMember]` 863 An iterator over the bungie clan members. 864 865 Raises 866 ------ 867 `aiobungie.NotFound` 868 The clan was not found. 869 """ 870 resp = await self.rest.fetch_clan_members(clan_id, type=type, name=name) 871 872 return self._framework.deserialize_clan_members(resp)
Fetch Bungie clan members.
Parameters
- clan_id (
int
): The clans id
Other Parameters
- name (
str | None
): If provided, Only players matching this name will be returned. - type (
aiobungie.MembershipType
): An optional clan member's membership type. This parameter is used to filter the returned results by the provided membership, For an example XBox memberships only, Otherwise will return all memberships.
Returns
Iterator[aiobungie.crates.ClanMember]
: An iterator over the bungie clan members.
Raises
aiobungie.NotFound
: The clan was not found.
887 async def kick_clan_member( 888 self, 889 access_token: str, 890 /, 891 group_id: int, 892 membership_id: int, 893 membership_type: enums.MembershipType | int, 894 ) -> clans.Clan: 895 """Kick a member from the clan. 896 897 .. note:: 898 This request requires OAuth2: oauth2: `AdminGroups` scope. 899 900 Parameters 901 ---------- 902 access_token : `str` 903 The bearer access token associated with the bungie account. 904 group_id: `int` 905 The group id. 906 membership_id : `int` 907 The member id to kick. 908 membership_type : `aiobungie.aiobungie.MembershipType | int` 909 The member's membership type. 910 911 Returns 912 ------- 913 `aiobungie.crates.clan.Clan` 914 The clan that the member was kicked from. 915 """ 916 resp = await self.rest.kick_clan_member( 917 access_token, 918 group_id=group_id, 919 membership_id=membership_id, 920 membership_type=membership_type, 921 ) 922 923 return self._framework.deserialize_clan(resp)
Kick a member from the clan.
This request requires OAuth2: oauth2: AdminGroups
scope.
Parameters
- access_token (
str
): The bearer access token associated with the bungie account. - group_id (
int
): The group id. - membership_id (
int
): The member id to kick. - membership_type (
aiobungie.aiobungie.MembershipType | int
): The member's membership type.
Returns
aiobungie.crates.clan.Clan
: The clan that the member was kicked from.
925 async def fetch_clan_weekly_rewards(self, clan_id: int) -> milestones.Milestone: 926 """Fetch a Bungie clan's weekly reward state. 927 928 Parameters 929 ---------- 930 clan_id : `int` 931 The clan's id. 932 933 Returns 934 ------- 935 `aiobungie.crates.Milestone` 936 A runtime status of the clan's milestone data. 937 """ 938 939 resp = await self.rest.fetch_clan_weekly_rewards(clan_id) 940 941 return self._framework.deserialize_milestone(resp)
Fetch a Bungie clan's weekly reward state.
Parameters
- clan_id (
int
): The clan's id.
Returns
aiobungie.crates.Milestone
: A runtime status of the clan's milestone data.
943 async def search_group( 944 self, 945 name: str, 946 group_type: enums.GroupType | int, 947 *, 948 creation_date: clans.GroupDate | int = 0, 949 sort_by: int | None = None, 950 group_member_count_filter: typing.Literal[0, 1, 2, 3] | None = None, 951 locale_filter: str | None = None, 952 tag_text: str | None = None, 953 items_per_page: int | None = None, 954 current_page: int | None = None, 955 request_token: str | None = None, 956 ) -> collections.Sequence[clans.Group]: 957 """Search for groups. 958 959 .. note:: 960 If the group type is set to `CLAN`, then parameters `group_member_count_filter`, 961 `locale_filter` and `tag_text` must be `None`, otherwise `ValueError` will be raised. 962 963 Parameters 964 ---------- 965 name : `str` 966 The group name. 967 group_type : `aiobungie.GroupType | int` 968 The group type that's being searched for. 969 970 Other Parameters 971 ---------------- 972 creation_date : `aiobungie.GroupDate | int` 973 The creation date of the group. Defaults to `0` which is all time. 974 sort_by : `int | None` 975 ... 976 group_member_count_filter : `int | None` 977 ... 978 locale_filter : `str | None` 979 ... 980 tag_text : `str | None` 981 ... 982 items_per_page : `int | None` 983 ... 984 current_page : `int | None` 985 ... 986 request_token : `str | None` 987 ... 988 989 Returns 990 -------- 991 `collections.Sequence[aiobungie.crates.Group]` 992 An array that contains the groups that match the search criteria. 993 994 Raises 995 ------ 996 `ValueError` 997 If the group type is `aiobungie.GroupType.CLAN` and `group_member_count_filter`, 998 `locale_filter` and `tag_text` are not `None`. 999 """ 1000 response = await self._rest.search_group( 1001 name, 1002 group_type, 1003 sort_by=sort_by, 1004 creation_date=creation_date, 1005 group_member_count_filter=group_member_count_filter, 1006 locale_filter=locale_filter, 1007 tag_text=tag_text, 1008 items_per_page=items_per_page, 1009 current_page=current_page, 1010 request_token=request_token, 1011 ) 1012 return tuple( 1013 self._framework.deserialize_group(result) for result in response["results"] 1014 )
Search for groups.
If the group type is set to CLAN
, then parameters group_member_count_filter
,
locale_filter
and tag_text
must be None
, otherwise ValueError
will be raised.
Parameters
- name (
str
): The group name. - group_type (
aiobungie.GroupType | int
): The group type that's being searched for.
Other Parameters
- creation_date (
aiobungie.GroupDate | int
): The creation date of the group. Defaults to0
which is all time. - sort_by (
int | None
): ... - group_member_count_filter (
int | None
): ... - locale_filter (
str | None
): ... - tag_text (
str | None
): ... - items_per_page (
int | None
): ... - current_page (
int | None
): ... - request_token (
str | None
): ...
Returns
collections.Sequence[aiobungie.crates.Group]
: An array that contains the groups that match the search criteria.
Raises
ValueError
: If the group type isaiobungie.GroupType.CLAN
andgroup_member_count_filter
,locale_filter
andtag_text
are notNone
.
1018 async def fetch_inventory_item(self, hash: int, /) -> entity.InventoryEntity: 1019 """Fetch a static inventory item entity given a its hash. 1020 1021 Parameters 1022 ---------- 1023 hash: `int` 1024 Inventory item's hash. 1025 1026 Returns 1027 ------- 1028 `aiobungie.crates.InventoryEntity` 1029 A bungie inventory item. 1030 """ 1031 resp = await self.rest.fetch_inventory_item(hash) 1032 1033 return self._framework.deserialize_inventory_entity(resp)
Fetch a static inventory item entity given a its hash.
Parameters
- hash (
int
): Inventory item's hash.
Returns
aiobungie.crates.InventoryEntity
: A bungie inventory item.
1035 async def fetch_objective_entity(self, hash: int, /) -> entity.ObjectiveEntity: 1036 """Fetch a Destiny objective entity given a its hash. 1037 1038 Parameters 1039 ---------- 1040 hash: `int` 1041 objective's hash. 1042 1043 Returns 1044 ------- 1045 `aiobungie.crates.ObjectiveEntity` 1046 An objective entity item. 1047 """ 1048 resp = await self.rest.fetch_objective_entity(hash) 1049 1050 return self._framework.deserialize_objective_entity(resp)
Fetch a Destiny objective entity given a its hash.
Parameters
- hash (
int
): objective's hash.
Returns
aiobungie.crates.ObjectiveEntity
: An objective entity item.
1052 @helpers.unstable 1053 async def search_entities( 1054 self, name: str, entity_type: str, *, page: int = 0 1055 ) -> sain.Iterator[entity.SearchableEntity]: 1056 """Search for Destiny2 entities given a name and its type. 1057 1058 Parameters 1059 ---------- 1060 name : `str` 1061 The name of the entity, i.e., Thunderlord, One thousand voices. 1062 entity_type : `str` 1063 The type of the entity, AKA Definition, 1064 For an example `DestinyInventoryItemDefinition` for emblems, weapons, and other inventory items. 1065 1066 Other Parameters 1067 ---------------- 1068 page : `int` 1069 An optional page to return. Default to 0. 1070 1071 Returns 1072 ------- 1073 `Iterator[aiobungie.crates.SearchableEntity]` 1074 An iterator over the found results matching the provided name. 1075 """ 1076 # resp = await self.rest.search_entities(name, entity_type, page=page) 1077 # calling this method will raise anyways. 1078 raise
Search for Destiny2 entities given a name and its type.
Parameters
- name (
str
): The name of the entity, i.e., Thunderlord, One thousand voices. - entity_type (
str
): The type of the entity, AKA Definition, For an exampleDestinyInventoryItemDefinition
for emblems, weapons, and other inventory items.
Other Parameters
- page (
int
): An optional page to return. Default to 0.
Returns
Iterator[aiobungie.crates.SearchableEntity]
: An iterator over the found results matching the provided name.
1082 async def fetch_fireteams( 1083 self, 1084 activity_type: fireteams.FireteamActivity | int, 1085 *, 1086 platform: fireteams.FireteamPlatform | int = fireteams.FireteamPlatform.ANY, 1087 language: fireteams.FireteamLanguage | str = fireteams.FireteamLanguage.ALL, 1088 date_range: int = 0, 1089 page: int = 0, 1090 slots_filter: int = 0, 1091 ) -> collections.Sequence[fireteams.Fireteam]: 1092 """Fetch public Bungie fireteams with open slots. 1093 1094 Parameters 1095 ---------- 1096 activity_type : `aiobungie.aiobungie.crates.FireteamActivity | int` 1097 The fireteam activity type. 1098 1099 Other Parameters 1100 ---------------- 1101 platform : `aiobungie.aiobungie.crates.fireteams.FireteamPlatform | int` 1102 If this is provided. Then the results will be filtered with the given platform. 1103 Defaults to `aiobungie.crates.FireteamPlatform.ANY` which returns all platforms. 1104 language : `aiobungie.crates.fireteams.FireteamLanguage | str` 1105 A locale language to filter the used language in that fireteam. 1106 Defaults to `aiobungie.crates.FireteamLanguage.ALL` 1107 date_range : `int` 1108 An integer to filter the date range of the returned fireteams. Defaults to `aiobungie.FireteamDate.ALL`. 1109 page : `int` 1110 The page number. By default its `0` which returns all available activities. 1111 slots_filter : `int` 1112 Filter the returned fireteams based on available slots. Default is `0` 1113 1114 Returns 1115 ------- 1116 `collections.Sequence[fireteams.Fireteam]` 1117 A sequence of `aiobungie.crates.Fireteam`. 1118 """ 1119 1120 resp = await self.rest.fetch_fireteams( 1121 activity_type, 1122 platform=platform, 1123 language=language, 1124 date_range=date_range, 1125 page=page, 1126 slots_filter=slots_filter, 1127 ) 1128 1129 return self._framework.deserialize_fireteams(resp)
Fetch public Bungie fireteams with open slots.
Parameters
- activity_type (
aiobungie.aiobungie.crates.FireteamActivity | int
): The fireteam activity type.
Other Parameters
- platform (
aiobungie.aiobungie.crates.fireteams.FireteamPlatform | int
): If this is provided. Then the results will be filtered with the given platform. Defaults toaiobungie.crates.FireteamPlatform.ANY
which returns all platforms. - language (
aiobungie.crates.fireteams.FireteamLanguage | str
): A locale language to filter the used language in that fireteam. Defaults toaiobungie.crates.FireteamLanguage.ALL
- date_range (
int
): An integer to filter the date range of the returned fireteams. Defaults toaiobungie.FireteamDate.ALL
. - page (
int
): The page number. By default its0
which returns all available activities. - slots_filter (
int
): Filter the returned fireteams based on available slots. Default is0
Returns
collections.Sequence[fireteams.Fireteam]
: A sequence ofaiobungie.crates.Fireteam
.
1131 async def fetch_available_clan_fireteams( 1132 self, 1133 access_token: str, 1134 group_id: int, 1135 activity_type: fireteams.FireteamActivity | int, 1136 *, 1137 platform: fireteams.FireteamPlatform | int, 1138 language: fireteams.FireteamLanguage | str, 1139 date_range: int = 0, 1140 page: int = 0, 1141 public_only: bool = False, 1142 slots_filter: int = 0, 1143 ) -> collections.Sequence[fireteams.Fireteam]: 1144 """Fetch a clan's fireteams with open slots. 1145 1146 .. note:: 1147 This method requires OAuth2: ReadGroups scope. 1148 1149 Parameters 1150 ---------- 1151 access_token : `str` 1152 The bearer access token associated with the bungie account. 1153 group_id : `int` 1154 The group/clan id of the fireteam. 1155 activity_type : `aiobungie.aiobungie.crates.FireteamActivity | int` 1156 The fireteam activity type. 1157 1158 Other Parameters 1159 ---------------- 1160 platform : `aiobungie.aiobungie.crates.fireteams.FireteamPlatform | int` 1161 If this is provided. Then the results will be filtered with the given platform. 1162 Defaults to `aiobungie.crates.FireteamPlatform.ANY` which returns all platforms. 1163 language : `aiobungie.crates.fireteams.FireteamLanguage | str` 1164 A locale language to filter the used language in that fireteam. 1165 Defaults to `aiobungie.crates.FireteamLanguage.ALL` 1166 date_range : `int` 1167 An integer to filter the date range of the returned fireteams. Defaults to `0`. 1168 page : `int` 1169 The page number. By default its `0` which returns all available activities. 1170 public_only: `bool` 1171 If set to True, Then only public fireteams will be returned. 1172 slots_filter : `int` 1173 Filter the returned fireteams based on available slots. Default is `0` 1174 1175 Returns 1176 ------- 1177 `collections.Sequence[aiobungie.crates.Fireteam]` 1178 A sequence of fireteams found in the clan. 1179 `None` will be returned if nothing was found. 1180 """ 1181 resp = await self.rest.fetch_available_clan_fireteams( 1182 access_token, 1183 group_id, 1184 activity_type, 1185 platform=platform, 1186 language=language, 1187 date_range=date_range, 1188 page=page, 1189 public_only=public_only, 1190 slots_filter=slots_filter, 1191 ) 1192 1193 return self._framework.deserialize_fireteams(resp)
Fetch a clan's fireteams with open slots.
This method requires OAuth2: ReadGroups scope.
Parameters
- access_token (
str
): The bearer access token associated with the bungie account. - group_id (
int
): The group/clan id of the fireteam. - activity_type (
aiobungie.aiobungie.crates.FireteamActivity | int
): The fireteam activity type.
Other Parameters
- platform (
aiobungie.aiobungie.crates.fireteams.FireteamPlatform | int
): If this is provided. Then the results will be filtered with the given platform. Defaults toaiobungie.crates.FireteamPlatform.ANY
which returns all platforms. - language (
aiobungie.crates.fireteams.FireteamLanguage | str
): A locale language to filter the used language in that fireteam. Defaults toaiobungie.crates.FireteamLanguage.ALL
- date_range (
int
): An integer to filter the date range of the returned fireteams. Defaults to0
. - page (
int
): The page number. By default its0
which returns all available activities. - public_only (
bool
): If set to True, Then only public fireteams will be returned. - slots_filter (
int
): Filter the returned fireteams based on available slots. Default is0
Returns
collections.Sequence[aiobungie.crates.Fireteam]
: A sequence of fireteams found in the clan.None
will be returned if nothing was found.
1195 async def fetch_clan_fireteam( 1196 self, access_token: str, fireteam_id: int, group_id: int 1197 ) -> fireteams.AvailableFireteam: 1198 """Fetch a specific clan fireteam. 1199 1200 .. note:: 1201 This method requires OAuth2: ReadGroups scope. 1202 1203 Parameters 1204 ---------- 1205 access_token : `str` 1206 The bearer access token associated with the bungie account. 1207 group_id : `int` 1208 The group/clan id to fetch the fireteam from. 1209 fireteam_id : `int` 1210 The fireteam id to fetch. 1211 1212 Returns 1213 ------- 1214 `aiobungie.crates.AvailableFireteam` 1215 A sequence of available fireteams objects. 1216 """ 1217 resp = await self.rest.fetch_clan_fireteam(access_token, fireteam_id, group_id) 1218 1219 return self._framework.deserialize_available_fireteam(resp)
Fetch a specific clan fireteam.
This method requires OAuth2: ReadGroups scope.
Parameters
- access_token (
str
): The bearer access token associated with the bungie account. - group_id (
int
): The group/clan id to fetch the fireteam from. - fireteam_id (
int
): The fireteam id to fetch.
Returns
aiobungie.crates.AvailableFireteam
: A sequence of available fireteams objects.
1221 async def fetch_my_clan_fireteams( 1222 self, 1223 access_token: str, 1224 group_id: int, 1225 *, 1226 include_closed: bool = True, 1227 platform: fireteams.FireteamPlatform | int, 1228 language: fireteams.FireteamLanguage | str, 1229 filtered: bool = True, 1230 page: int = 0, 1231 ) -> collections.Sequence[fireteams.AvailableFireteam]: 1232 """A method that's similar to `fetch_fireteams` but requires OAuth2. 1233 1234 .. note:: 1235 This method requires OAuth2: ReadGroups scope. 1236 1237 Parameters 1238 ---------- 1239 access_token : str 1240 The bearer access token associated with the bungie account. 1241 group_id : int 1242 The group/clan id to fetch. 1243 1244 Other Parameters 1245 ---------------- 1246 include_closed : `bool` 1247 If provided and set to True, It will also return closed fireteams. 1248 If provided and set to False, It will only return public fireteams. Default is True. 1249 platform : aiobungie.aiobungie.crates.fireteams.FireteamPlatform | int 1250 If this is provided. Then the results will be filtered with the given platform. 1251 Defaults to aiobungie.crates.FireteamPlatform.ANY which returns all platforms. 1252 language : `aiobungie.crates.fireteams.FireteamLanguage | str` 1253 A locale language to filter the used language in that fireteam. 1254 Defaults to aiobungie.crates.FireteamLanguage.ALL 1255 filtered : `bool` 1256 If set to True, it will filter by clan. Otherwise not. Default is True. 1257 page : `int` 1258 The page number. By default its 0 which returns all available activities. 1259 1260 Returns 1261 ------- 1262 `collections.Sequence[aiobungie.crates.AvailableFireteam]` 1263 A sequence of available fireteams objects if exists. else `None` will be returned. 1264 """ 1265 resp = await self.rest.fetch_my_clan_fireteams( 1266 access_token, 1267 group_id, 1268 include_closed=include_closed, 1269 platform=platform, 1270 language=language, 1271 filtered=filtered, 1272 page=page, 1273 ) 1274 1275 return self._framework.deserialize_available_fireteams(resp)
A method that's similar to fetch_fireteams
but requires OAuth2.
This method requires OAuth2: ReadGroups scope.
Parameters
- access_token (str): The bearer access token associated with the bungie account.
- group_id (int): The group/clan id to fetch.
Other Parameters
- include_closed (
bool
): If provided and set to True, It will also return closed fireteams. If provided and set to False, It will only return public fireteams. Default is True. - platform (aiobungie.aiobungie.crates.fireteams.FireteamPlatform | int): If this is provided. Then the results will be filtered with the given platform. Defaults to aiobungie.crates.FireteamPlatform.ANY which returns all platforms.
- language (
aiobungie.crates.fireteams.FireteamLanguage | str
): A locale language to filter the used language in that fireteam. Defaults to aiobungie.crates.FireteamLanguage.ALL - filtered (
bool
): If set to True, it will filter by clan. Otherwise not. Default is True. - page (
int
): The page number. By default its 0 which returns all available activities.
Returns
collections.Sequence[aiobungie.crates.AvailableFireteam]
: A sequence of available fireteams objects if exists. elseNone
will be returned.
1279 async def fetch_friends( 1280 self, access_token: str, / 1281 ) -> collections.Sequence[friends.Friend]: 1282 """Fetch bungie friend list. 1283 1284 .. note:: 1285 This requests OAuth2: ReadUserData scope. 1286 1287 Parameters 1288 ----------- 1289 access_token : `str` 1290 The bearer access token associated with the bungie account. 1291 1292 Returns 1293 ------- 1294 `collections.Sequence[aiobungie.crates.Friend]` 1295 A sequence of the friends associated with that access token. 1296 """ 1297 1298 resp = await self.rest.fetch_friends(access_token) 1299 1300 return self._framework.deserialize_friends(resp)
Fetch bungie friend list.
This requests OAuth2: ReadUserData scope.
Parameters
- access_token (
str
): The bearer access token associated with the bungie account.
Returns
collections.Sequence[aiobungie.crates.Friend]
: A sequence of the friends associated with that access token.
1302 async def fetch_friend_requests( 1303 self, access_token: str, / 1304 ) -> friends.FriendRequestView: 1305 """Fetch pending bungie friend requests queue. 1306 1307 .. note:: 1308 This requests OAuth2: ReadUserData scope. 1309 1310 Parameters 1311 ----------- 1312 access_token : `str` 1313 The bearer access token associated with the bungie account. 1314 1315 Returns 1316 ------- 1317 `aiobungie.crates.FriendRequestView` 1318 A friend requests view of that associated access token. 1319 """ 1320 1321 resp = await self.rest.fetch_friend_requests(access_token) 1322 1323 return self._framework.deserialize_friend_requests(resp)
Fetch pending bungie friend requests queue.
This requests OAuth2: ReadUserData scope.
Parameters
- access_token (
str
): The bearer access token associated with the bungie account.
Returns
aiobungie.crates.FriendRequestView
: A friend requests view of that associated access token.
1327 async def fetch_application(self, appid: int, /) -> application.Application: 1328 """Fetch a Bungie application. 1329 1330 Parameters 1331 ----------- 1332 appid: `int` 1333 The application id. 1334 1335 Returns 1336 -------- 1337 `aiobungie.crates.Application` 1338 A Bungie application. 1339 """ 1340 resp = await self.rest.fetch_application(appid) 1341 1342 return self._framework.deserialize_application(resp)
Fetch a Bungie application.
Parameters
- appid (
int
): The application id.
Returns
aiobungie.crates.Application
: A Bungie application.
1346 async def fetch_public_milestone_content( 1347 self, milestone_hash: int, / 1348 ) -> milestones.MilestoneContent: 1349 """Fetch the milestone content given its hash. 1350 1351 Parameters 1352 ---------- 1353 milestone_hash : `int` 1354 The milestone hash. 1355 1356 Returns 1357 ------- 1358 `aiobungie.crates.milestones.MilestoneContent` 1359 A milestone content object. 1360 """ 1361 ... 1362 resp = await self.rest.fetch_public_milestone_content(milestone_hash) 1363 return self._framework.deserialize_public_milestone_content(resp)
Fetch the milestone content given its hash.
Parameters
- milestone_hash (
int
): The milestone hash.
Returns
aiobungie.crates.milestones.MilestoneContent
: A milestone content object.