Skip to content
/ BungIO Public

BungIO is a modern and pythonic wrapper for Bungies Destiny 2 API.

License

Notifications You must be signed in to change notification settings

Kigstn/BungIO

Repository files navigation

BungIO Logo

BungIO


BungIO is a modern and pythonic wrapper for Bungies Destiny 2 API.

  • Python 3.10+
  • Asynchronous
  • 100% typed and raw api coverage
  • Ratelimit compliant
  • Manifest support
  • OAuth2 support
  • Easily used in combination with other libraries like FastApi

Click here to get started or visit the guides or api reference.

Why BungIO?

What sets this library apart from other projects is that it has full api coverage - every single route is fully typed and returns fully typed python classes! And better yet, the api is automatically generated from the api spec bungie publishes. This means when there is an update to the api, it needs literally one button click from me to update the library to the latest api version with the new shiny features.

This means that all api features are fully supported and support for new API feature is added in seconds. This has the downside, that everything follows the Bungie API spec - so if there is an error in the published spec, the same error will be in this library.

Destiny Manifest Support

The manifest is where bungie defines all their data: activities, emblems, items, etc. Normally you need to constantly look up data from the api in the manifest, because the api only returns basic info / ids.

For example: You want to look up what activity your user has done last. So you call the correct api route which returns an activity id. You then have to download the manifest and look up that activity id in the correct manifest location. Only then you get additional information like the activity name, light level, location, etc. As you can probably imagine, this gets annoying veeeery quickly.

BungIO provides helper functions to make manifest lookups stupidly easy. Take a look at the manifest guide for more information :)

Basic Example

import asyncio
import os

from bungio import Client
from bungio.models import BungieMembershipType, DestinyActivityModeType, DestinyUser


# create the client obj with our bungie authentication
client = Client(
    bungie_client_id=os.getenv("BUNGIE_CLIENT_ID"),
    bungie_client_secret=os.getenv("BUNGIE_CLIENT_SECRET"),
    bungie_token=os.getenv("BUNGIE_TOKEN"),
)

async def main():
    # create a user obj using a known bungie id
    user = DestinyUser(membership_id=4611686018467765462, membership_type=BungieMembershipType.TIGER_STEAM)

    # iterate thought the raids that user has played
    async for activity in user.yield_activity_history(mode=DestinyActivityModeType.RAID):

        # print the date of the activity
        print(activity.period)

# bungio is by nature asynchronous, it can only be run in an asynchronous context
asyncio.run(main())

Dev Setup

Install Dependencies

Run Tests

  • uv run pytest .

Run Docs

  • uv run mkdocs serve

About

BungIO is a modern and pythonic wrapper for Bungies Destiny 2 API.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published

Languages