Skip to main content

aiobungie

An ergonomic, statically typed, asynchronous API wrapper that supports Bungie's REST API for Python 3.

aiobungie is built to be extensible and reusable, allowing its users to freely switch parts of core implementations with their own incase of future circumstances.

Installing

Currently Python 3.10, 3.11, 3.12 and 3.13 are supported.

Stable pip.

pip install aiobungie

unstable releases via GitHub master.

pip install git+https://github.com/nxtlo/aiobungie@master

Quick Look

See Examples for advance usage.

import aiobungie
import asyncio

client = aiobungie.Client('YOUR_API_KEY')

async def main() -> None:
    # Search for Destiny 2 players.
    async with client.rest:
        users = await client.search_users("Fate")

      for user in users:
        # Print all Destiny 2 memberships for this user.
        print(user.memberships)


asyncio.run(main())

RESTful clients

aiobungie also provides a stand-alone RESTClient / RESTPool clients which are the foundation of Client, These clients just provide a lower-level abstraction.

a Client based user may access the RESTClient instance bound to it with .rest property.

Example

import aiobungie
import asyncio

# Single REST client connection.
client = aiobungie.RESTClient("YOUR_API_KEY")

async def main() -> None:
    async with client:
        # Download and open the JSON manifest.
        manifest = await client.download_json_manifest(name="latest_manifest")
        with manifest.open("r") as file:
            data = file.read()

        # two simple methods for fetching and refreshing tokens.
        tokens = await client.fetch_oauth2_tokens('code')
        refreshed_tokens = await client.refresh_access_token(tokens.refresh_token)

        # making your own requests.
        response = await client.static_request(
            "GET", # Method.
            "Destiny2/path/to/route", # Route.
            auth="optional_access_token", # If the method requires OAuth2.
            json={"some_key": "some_value"} # If you need to pass JSON data.
        )

asyncio.run(main())

When to use which?

  • Use Client when:
    • You want a high-level interface.
    • You're building a Bot, i.e, Discord Bot, Chat Bot.
    • You're building a CLI tool.
    • In a single script file.
  • Use RESTClient when:
    • You want an interface similar to Client but with extra functionalities.
    • You want raw JSON responses instead of data-classes.
    • You want REST API functionalities.
    • You want full ownership of the requests/responses.
  • Use RESTPool when:
    • everything RESTClient provides.
    • You want to spawn multiple RESTClients.
    • You're building a distributed backend.

Dependencies

  • aiohttp
  • attrs
  • sain, this is a dependency free utility package.
  • backports.datetime_fromisoformat, required for Python 3.10 only.

Features

aiobungie features are extra dependencies that replaces the standard library with either faster/neater pkgs.

  • speedup This will include and use orjson as the default json parser. It provide faster JSON serialization and de-serialization than the standard Python JSON pkg.
  • full: This will include all of the features above.

For installing the specified feature, type pip install aiobungie[feature-name]

Optimizations

  • runtime-assertion: You can disable runtime assertions by passing a -O flag python app.py -O, the API responses won't get asserted at runtime which may boost the return speeds by a bit.
  • uvloop (unix systems only): uvloop is an ultra-fast drop in replacement library for the built-in asyncio event loop.

Contributing

Please read this manual

Related Projects

If you have used aiobungie and want to show your work, Feel free to Open a PR including it.

  • Fated: A Discord BOT that uses aiobungie.

Useful Resources

  • Discord Username: vfate
  • aiobungie Documentation: Here.
  • BungieAPI Discord: Here
  • Official Bungie Documentation: Here
  • Bungie Developer Portal: Here

Notes

  • If you need help with something related to this project: Consider opening a blank issue, discussion or checkout the useful resources above.
  • aiobungie doesn't support X update, what now? aiobungie's REST client has a method called static_request which allows you to make your own requests, check out examples/custom_client example.
  • aiobungie's release cycles are slow, It takes a couple of months between each release, Some features / routes may not be available on stable version, though, it is still possible to define your own routes on top of aiobungie's clients foundation.

Release files for aiobungie 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiobungie 0.5.0
File Size Uploaded
aiobungie-0.5.0.tar.gz 114.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiobungie 0.5.0
File Interpreter ABI Platform
aiobungie-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 259.2 kB

Release files / aiobungie-0.5.0.tar.gz

Download URL aiobungie-0.5.0.tar.gz
Size 114.7 kB
Tags Source
SHA-256 checksum
How to use checksums
fd048af40545b2354ff8d4be91c0c9d162dfe34d2f4414244a057ee30e0c0b76
BLAKE2b-256 checksum
How to use checksums
3b22d4a2f06b65838223ef1b8cc2fa7dc9a82449293d4b2cfb5e3bd48548af02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.3 Linux/6.11.0-1018-azure

Release files / aiobungie-0.5.0-py3-none-any.whl

Download URL aiobungie-0.5.0-py3-none-any.whl
Size 144.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
58841a080b45193af3430d98d3f51ad49261768ecf503665b70bf9cd88f9f870
BLAKE2b-256 checksum
How to use checksums
30b203d43088af14b1c1685b75cb8e86d54a3f08fef610e708d28a0990f3bedc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.3 Linux/6.11.0-1018-azure

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.10

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page