Releases: nxtlo/aiobungie
0.4.0
Added
- Python 3.13 Support. i know, it has been months since this released.
framework.Global
is a pre initialized instance alternative toaiobungie.Empty
.- You can customize the behavior of certain HTTP parameters via
aiobungie.builders.Settings
object, This can be used in any client implementation, Example:
import aiobungie
from aiobungie.builders import Settings
# By default, it initialize pre-configured.
# You can checkout the documentations for more details
# on what you can configure.
default = Settings()
client = aiobungie.RESTClient("token", settings=default)
- A
settings
property on both client implementations. owned_client
parameter toRESTClient
, This allows you to use
your ownaiohttp.ClientSession
instance, Example.
import aiobungie
import aiohttp
my_session = aiohttp.ClientSession()
# What `owned_client=False` means here is we're using our own TCP session.
client = aiobungie.RESTClient("token", owned_client=False, client_session=my_session)
async with client:
...
This is useful if you're using one session for the entire lifetime of the program
which's also being used in different parts of the program,
Removed
ujson
is no longer supported. See WhyEmpty
framework, This was supposed to be removed in0.3.1
.
Changed
- You need to open and close the HTTP connection by yourself when using
RESTPool
, Example:
import aiobungie
pool = aiobungie.RESTPool("token")
async def start():
# Starting point of the program
await pool.start()
async def runtime():
# We know that the pool connection is open
# at this point of the program.
async with pool.acquire() as client:
...
async def closing():
# Exit point of the program
await pool.stop()
- The method
search_entnties
is currently marked asunstable
until a further fix, This is a Bungie problem. - Methods such as
RESTClient._handle_ratelimit
andRESTClient.open/close
has been unmarked as@final
methods, which allows you to write your own logic.
Fixed
- The
TRACE
debugging level no longer outputs sensitive data.
0.3.1
0.3.0
This release contains a lot of changes, please read this if you're a user of this library.
Added
methods
fetch_sanitized_membership
, available on both client APIssearch_groups
, available on both client APIsRESTClient.report_player
RESTClient.force_drops_repair
RESTClient.claim_partner_offer
RESTClient.fetch_bungie_rewards_for_user
RESTClient.fetch_bungie_rewards_for_platform
RESTClient.fetch_bungie_rewards
Image.stream
Image.chunks
FireteamFinder
methods, available through theRESTClient.build_fireteam_finder
method.
components
- implemented the
CHARACTER LOADOUTS
component along with its framework methods, You can access it viaComponents.character_loadouts
after fetching a profile. orloadouts
after fetching a character. - implemented the
SOCIAL COMMENDATIONS
components, you can access it viaComponents.commendations
after fetching a profile.
object fields
type
,profile_ban_expire
andegs_name
fields toBungieUser
code
field toPartialBungieUser
origin
field toApplication
emblem_color
field toCharacter
minutes_played_this_session
field toCharacter
percent_to_next_level
field toCharacter
- Added the following to
Profile
season_hashes
versions_owned
season_hash
guardian_rank
highest_guardian_rank
renewed_guardian_rank
event_card_hashes
user
, removedname
,id
andtype
in favor of this.
- Added
available_activity_interactables
toCharacterActivity
other
sain
as a required dependency. this is used mainly to replaceiterators
custom_client
exampleGameVersions
enum.- An option to use a specific executor for downloading the manifest and
Image.save
method.
import concurrent.futures
# Use process pool executor to write the manifest data.
await rest.download_json_manifest(
...,
executor=concurrent.futures.ProcessPoolExecutor()
)
FireteamBuilder
inaiobungie.builders
Changed
name changes
interfaces
dir is renamed toapi
.factory
renamed toframework
and exported to top level, no longer aninternal
packagefactory.Factory
is nowframework.Framework
.interfaces.RESTInterface
renamed toapi.RESTClient
which matchesrest.RESTClient
.interfaces.FactoryInterface
renamed toapi.Framework
which matchesframework.Framework
.- trait
Netrunner
renamed toSend
and is no longer used, currently kept for future plans. - trait
Serializable
renamed toDeserialize
and its methodfactory
renamed toframework
. - trait
ClientApp
renamed toCompact
. Client.factory
is nowClient.framework
.factory.EmptyFactory
is nowframework.Empty
and is now deprecated, useFramework()
instead.UserLike
abstract class renamed toUnique
.deserialize_app
renamed todeserialize_application
.deserialize_app_owner
renamed todeserialize_application_member
ApplicationOwner
is nowApplicationMember
and the user fields are accessible through.user
Application.owner
field is nowApplication.team
which returns the entire application roaster instead of just the owner.Framework.deserialize_fireteam_destiny_users
renamed todeserialize_fireteam_destiny_membership
FireteamMember.destiny_user
renamed toFireteamMember.membership
Image.default_or_else
is now justImage.default
other changes
Framework
doesn't require anet
parameter anymore.Client.run
is deprecated and will be removed in the next major release.RESTClient.with_debug
has been moved totraits.RESTful
with a default final impl.internal.assets
which containedImage
has been moved toaiobungie.builders
Image
now acceptsNone
as a default path.sain
package is now used as the default iterator builder.
it is a dependency free that's developed by me so it won't really have any side-effects.- If you're a
RESTPool
user, it is possible to callbuild_oauth2_url
without acquiring a client instance
this is a good change for performance improvements since acquiring a client instance also means opening a TCP connection,
which is useless when you're still not making any requests.
pool = aiobungie.RESTPool("token", client_id=0000, client_secret="secret")
url = pool.build_oauth2_url()
# same as
async with pool.acquire() as client:
url = client.build_oauth2_url()
# also the same
url = pool.acquire().build_oauth2_url()
Removed
The following methods were scheduled to be removed in this version.
PartialBungieUser.fetch_self()
ProfileItemImpl.is_transferable
ProfileItemImpl.collect_characters
ProfileItemImpl.fetch_self
DestinyMembership.fetch_self_profile
QuesStatus.fetch_quest
QuestStatus.fetch_step
Objective.fetch_self
ItemsComponent.any
ItemsComponent.all
Challenges.fetch_objective
Rewards.fetch_self
Activity.is_solo
Activity.is_flawless
Activity.is_solo_flawless
Activity.fetch_post
Character.transfer_item
Character.equip_item
Character.equip_items
Character.pull_item
Character.fetch_activities
RenderedData.fetch_my_items
MinimalEquipments.fetch_my_item
AvailableActivity.fetch_self
ClanMember.ban
ClanMember.unban
ClanMember.kick
ClanMember.fetch_clan
GroupMember.fetch_self_clan
Clan.deny_pending_members
Clan.approve_pending_members
Clan.add_optional_conversations
Clan.fetch_banned_members
Clan.fetch_pending_members
Clan.fetch_invited_members
Clan.fetch_conversations
Clan.fetch_available_fireteams
Clan.fetch_fireteams
Clan.fetch_members
Clan.edit
Clan.edit_options
ClanConversation.edit
CraftablesComponent.fetch_craftables
SearchableEntity.fetch_self_item
these methods above are still accessible via the both clients, either the RESTClient
or Client
,
their abstraction on the object just got removed not that actual implementation of the method.
ok but how do i reproduce those?
client = aiobungie.Client("...")
async def character_transfer_item() -> None:
# Instead of: await character.transfer_item(...)
# call it from the client directly.
await client.rest.transfer_item(token, char_id, item_id)
async def character_fetch_activities() -> None:
# Instead of: await character.fetch_activities(...)
# call it from the client directly.
await client.fetch_activities(cid, mid, mode, ...)
ok but why? there're multiple reasons why those got removed.
good practices; at the beginning, those methods were meant to provide a higher-level abstraction over the object itself,
so you can call them directly from the object, while it is a nice QoL thing, it can, if misused, end up with worse overall code.
this change should forward users with developing good code and practices and make them more aware of both client APIs.
conflict and unsafety; since those methods can also be accessed via an empty deserializer results, this introduces bugs for the user of this lib,
Example:
framework = aiobungie.framework.Empty()
response = requests.get(...)
user_object = framework.deserialize_user(response.json())
# this is undefined behavior, since an empty deserializer doesn't have a client associated with it.
await user_object.fetch_self()
aiobungie crates are meant to be a stand-alone representation of the fetched API results. which payloads deserializes into. so those methods won't really fit in.
.net
field removed from all objects.UserLike.icon
UserLike.last_seen_name
UserLike.is_public
ComponentFields
enumImage.url
, useImage.create_url
instead.iterators
package in favor ofsain
Fixed
- deserializing
Friend
object was raisingKeyError
due toname
field. vault
option in methodpull_item
now works as intended, thanks to #418 for opening the issue.ComponentType.CHARACTER_PROGRESSIONS
enum field name typo fixed.
0.2.11
Highlights
- Object immutability, all objects are now frozen.
- All sequences are now built as tuples instead of list, This helps reducing the size of the allocated bytes
and increases the speed by a little bit since tuples are sized and lists are dynamic, This obviously depends on how
large the data that has been fetched. But in general tuples are faster. - You'll be getting deprecation warning on
crates
level helper methods. RESTClient.enable_debug
renamed toRESTClient.with_debug
method.
Added
Iterator.by_ref
method.- Installing option
full
by callingpip install aiobungie[full]
.
Removed
traits.Debug
trait.- The alias
crate
forcrates
is removed. Useaiobungie.crates
instead. rest.RequestMethod
enum.
Changed
- Logging an
Iterator
object now doesn't consume the data. set_item_lock_state
is currently unstable due to Bungie returning HTML.ClanMember.current_user_memberships
is now nullable.- Optimized factory deserialization methods.
- The
enable_debugging
parameter renamed todebug
. - You won't need to pass
True
when callingRESTClient.enable_debug
.
0.2.10
0.2.9
0.2.9 - 2023-12-1
Major Changes
- Python 3.10 and above is now required, 3.9.0 is no longer supported.
- Method
fetch_player
renamed tofetch_membership
. download_manifest
method has been renamed todownload_sqlite_manifest
Performance Improvements.
- Optimized converting
ISO8661
date strings to datetime,dateutil
package has been dropped and the converting process has been implemented directly using stdlib datetime. orjson
andujson
are a faster replacement for the JSON lib, If were found installed, They will be used as the default JSON encode/decoder.ruff
is now used as the default formatter. This is rather an internal change and shouldn't affect users.
Added
- Added more examples.
- Lightfall loadouts methods to the
RESTClient
.equip_loadout
clear_loadout
snapshot_loadout
update_loadout
CHARACTER_LOADOUTS
components type enum field.- If your Python version is
3.10
, A backport ofdatetime.fromisoformat
module will be installed.
This is required due to this specific Python version not able to parse some ISO date formats. aiobungie.EmptyFactory
object. See the object docs for more info.Iterator.last()
method which return the last item in the iterator.
Changed
User.destiny
renamed toUser.memberships
,ClanMember.bungie
toClanMember.bungie_user
,LinkedProfile.bungie
toLinkedProfile.bungie_user
for naming consistency.- Both download manifest methods now return
pathlib.Path
object. - All arguments in the client constructors now required to be passed as a kwarg besides the token.
- Refactor examples code.
Factory
methods that used to returnOptional[T]
now returns justT
.Enum.__int__
andFlag.__int__
doesn't check the instance of the type anymore.iterators.into_iter
function renamed toiterators.iter
.- Use new
str | None
union instead ofOptional[str, None]
- Improved documentations on objects.
- Some object field names has been typo fixed.
- Method
fetch_available_fireteams
typo name fixed. Character.total_played_time
now returns the total time in seconds instead of string.- Fields
emblem
,emblem_icon
andemblem_hash
are now Optional.
Removed
- The
net
field has been removed from some objects. - The
UNDEFINED
object, Fields now returnT or None
instead.
Fixed
- Fixed multiple buggy
Factory
methods. Factory.deserialize_character
was raisingKeyError
when accessing the emblem keys, Thanks to @spacez320 (#303)
0.2.8
Changed
- You can no longer pass
rest_client
instance toClient
object. Friend
object methods has been removed since they can be performed using theRESTClient
, Includingaccept
->rest.accept_friend_request
decline
->rest.decline_friend_request
remove
->rest.remove_friend
remove_request
->rest.remove_friend_request
- The
_info.py
package is renamed tometadata.py
. - Updated requirements versions.
Added
- New method added to
MembershipTypeError
exceptioninto_membership
which converts the membership from str toMembershipType
enum.
Removed
- Parameter
max_ratelimit_retries
removed from client impls.
0.2.7 release.
Breaking Changes
- Base
Client
users now will need to open the REST client before making any requests.
The old way.
import aiobungie
# Here the client will initialize the TCP connector even though
# we're still not planning on making any request which's not performant.
client = aiobungie.Client('...')
results = await client.fetch('...')
The new way
client = aiobungie.Client('...')
# Open the REST connection and use the client normally.
async with client.rest:
users = await client.search_users('...')
return users[0]
# Another way of doing that manually
# This must be called within an event loop
client.rest.open()
# Do stuff with the client...
# Close.
await client.rest.close()
build_oauth2_url
now returnsbuilders.OAuthURL
object instead of a string URL, This is intentionally changed to seperate
the state field from the URL. A fully generated URL can still be acquired via.compile()
method or.url
property.
Added
- Special method
__or__
toFlatIterator
which allows to union two iterators togather asx = iterator1 | iterator2
- New method
FlatIterator.async_for_each
, whichs equavilant tofor_each
but takes an async function instead.
Example:
async def signup(username: str) -> None:
async with aiohttp.request('POST', '...') as r:
# Actual logic.
...
async def main():
users = aiobungie.into_iter(["user_danny", "user_jojo"])
await users.async_for_each(lambda username: signup(username))
- Allow to customize where to download the manifest file.
Example:
await client.download_manifest(name='Destiny', path='G:/Files' or pathlib.Path("Path/**/**")) # -> G:/Files/Destiny.sqlite3
Added
- Enum fields
EPIC_GAMES_STORE
andDEMON
. #214
Changed
FlatIterator
no longer support async iteration.- Removed method
FlatIterator.discard
in favor ofFlatIterator.filter
mathod. FlatIterator
class renamed toIterator
.- Enum flags now uses bitwise
<<
for its fields instead of=
numbers assign.
Removed
CharacterError
exception. This was supposed to be removed with0.2.6
.
Fixed
- Docs colors.
0.2.6 update.
Highlights
-
Seson 17 new activities.
-
helpers.awaits
now returnsSequence
instead ofCollection
. -
RESTPool
impl. -
REST_DEBUG
level name toTRACE
-
aiobungie.crate
is renamed tocrates
+ Added an alias forcrate
for backward versions. -
RESTnterface
andRESTClient
is now completlyasync def
+ typesafe. -
PlugSocketBuilder
andOAuth2Response
has been moved tobuilders.py
and both objects are not exposed to the project namespace anymore. Howeveraiobungie.builders.*
is exposed. -
Objects no longer type hinted with
MaybeImage
and now returnImage
instead. -
All methods that used to take
*components
now take a list of component types instead. -
All components should be passed as is without unpacking nor using the
.value
attribute. -
The
auth
parameter is now exposed as an actual parameter and not a kwarg.
Example
await client.fetch_profile(
...,
components=[aiobungie.ComponentType.ALL_PROFILES, aiobungie.ComponentType.CHARACTERS, ...],
auth="..."
)
- Standard
FlatIterator
andinto_iter
ininternal.iterators
and exported to the project's namespace.
Example usage
import aiobungie
client = aiobungie.Client()
friends = await client.fetch_friends(...)
# This can either be used with `async for` or `for`
async for friend in (
aiobungie.into_iter(friends) # Transform the sequence into a flat iterator.
.filter(lambda friend: friend.type is MembershipType.STEAM) # Filter to only steam friends.
.take(5) # Limit the results to 5 friends
.discard(lambda friend: friend.online_status is Presence.ONLINE) # Drop friends that are not online.
.reversed() # Reverse them.
):
print(friend.unique_name)
RESTPool + typesafe RESTClient.
0.2.6a3 2022-05-8
Added
- New
builders.py
contains results of received/sent objects to the API. RESTPool
impl.
Changed
REST_DEBUG
level name toTRACE
enable_logging
parameter now acceptsstr | int | bool
.- Setting the level to
True
now will only log minimal information. PlugSocketBuilder
andOAuth2Response
has been moved tobuilders.py
and both objects are not exposed to the project namespace anymore. Howeveraiobungie.builders.*
is exposed.aiobungie.crate
is renamed tocrates
+ Added an alias forcrate
for backward versions.RESTnterface
andRESTClient
is now completlyasync def
+ typesafe.
Removed
Fixed
- Objective in metrics components was always returning
None