Skip to main content

A Python and Asyncio API wrapper for Bungie's API.

Project description

aiobungie

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

Installing

Currently Python 3.10, 3.11 and 3.12 are supported.

Latest Release using pip.

pip install aiobungie

Development via github master.

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

Quick Example

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 which's what Client built on top of, These clients just provide a lower-level abstraction.

A key note is that any Client based user can access the RESTClient instance bound to it with .rest property.

Key features

  • Lower level, allows to read and deserialize the JSON objects yourself.
  • RESTClients do not turn response payloads into one of aiobungie.crates object.
  • RESTful, You can use this as your REST API client in backend directly.
  • Both manifest and OAuth2 methods are usable directly.

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()

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

        # Testing 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())

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 uses orjson or ujson as the default json parser. They 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]

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

FaQ

  • I need help with something related to this project: Consider opening a blank issue, discussion or checkout the useful resources above.
  • aiobungie doesn't support fetch_xxx route, what now? aiobungie's REST client exposes a method called static_request which allows you to make your own requests, check out examples/custom_client example.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiobungie-0.3.1.tar.gz (112.6 kB view details)

Uploaded Source

Built Distribution

aiobungie-0.3.1-py3-none-any.whl (142.7 kB view details)

Uploaded Python 3

File details

Details for the file aiobungie-0.3.1.tar.gz.

File metadata

  • Download URL: aiobungie-0.3.1.tar.gz
  • Upload date:
  • Size: 112.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.14 Linux/6.5.0-1025-azure

File hashes

Hashes for aiobungie-0.3.1.tar.gz
Algorithm Hash digest
SHA256 b99f68fa96dd0317ae2bfa49e52e33b25561483f4e42390e35ff3be7d25f8ad4
MD5 624ad74a8480f290afc4cbb56200a96f
BLAKE2b-256 67fbded984640a49f4f64d58204fb135bd9f10a45a75c27e527ac460971eed34

See more details on using hashes here.

File details

Details for the file aiobungie-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: aiobungie-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 142.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.14 Linux/6.5.0-1025-azure

File hashes

Hashes for aiobungie-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6ddd928f958f54121b300d636d119902d88ceca869429a9a3c7f31e2d73ebca8
MD5 8b67e18466a52c1cb8b3878021fd86f0
BLAKE2b-256 7d3ede912aad9579a23fd15f055aabbd9304f3c277a482bd97a1e8ad46e9da31

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page