aiobungie


Nameaiobungie JSON
Version 0.2.11 PyPI version JSON
download
home_pagehttps://github.com/nxtlo/aiobungie
SummaryA Python and Asyncio API wrapper for Bungie's API.
upload_time2024-02-05 17:17:31
maintainer
docs_urlNone
authornxtlo
requires_python>=3.10.0,<3.13
licenseMIT
keywords async api destiny bungie
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # aiobungie

A statically typed, asynchronous API wrapper for building clients for Bungie's API in Python.

## Installing

Currently Python 3.10, 3.11 and 3.12 are supported.

Stable release.

```sh
pip install aiobungie
```

Development via github master.

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

## Quick Example

See [Examples for advance usage.](https://github.com/nxtlo/aiobungie/tree/master/examples)

```py
import aiobungie

client = aiobungie.Client('YOUR_API_KEY')

async def main() -> None:
    # Fetch a Destiny 2 character passing a component.
    # This includes Equipments, Inventory, Records, etc.
    async with client.rest:
        my_warlock = await client.fetch_character(
            member_id=4611686018484639825,
            membership_type=aiobungie.MembershipType.STEAM,
            character_id=2305843009444904605,
            components=[aiobungie.ComponentType.CHARACTER_EQUIPMENT],
        )
        # Other components will be populated when passed to `components=[...]`
        # Otherwise will be `None`

        # Make sure the component is fetched.
        assert my_warlock.equipment is not None

        # Get the first item equipped on this character.
        item = my_warlock.equipment[0]
        print(item.hash, item.location)

        # Fetch this item, Note that this performs an HTTP request.
        # Alternatively, You can use the manifest here instead.
        # See examples folder for more information.
        item = await client.fetch_inventory_item(item.hash)
        print(item.name, item.type_and_tier_name)
        # Prints: Izanagi's Burden Exotic Sniper Rifle

# You can either run it using the client or just asyncio.run(main())
client.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.
* `RESTClient`s 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 `OAuth` methods are usable directly.

### Example

```py
import aiobungie
import asyncio

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

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

## Dependancies

* aiohttp
* attrs
* `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](https://github.com/ijl/orjson) or [ujson](https://github.com/ultrajson/ultrajson)
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](https://github.com/nxtlo/aiobungie/blob/master/CONTRIBUTING.md)

## Related Projects

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

* [Fated](https://github.com/nxtlo/Fated/blob/master/core/components/destiny.py): A Discord BOT that uses aiobungie.

## Useful Resources

* Discord Username: `vfate`
* aiobungie Documentation: [Here](https://nxtlo.github.io/aiobungie/).
* BungieAPI Discord: [Here](https://discord.gg/vP7VC7TKUG)
* Official Bungie Documentation: [Here](https://bungie-net.github.io/multi/index.html)
* Bungie Developer Portal: [Here](https://www.bungie.net/en/Application)

### Additional information

If you have any question you can either open a blank issue, open a new github discussion, or just tag me in BungieAPI discord server.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/nxtlo/aiobungie",
    "name": "aiobungie",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10.0,<3.13",
    "maintainer_email": "",
    "keywords": "async,api,destiny,bungie",
    "author": "nxtlo",
    "author_email": "dhmony-99@hotmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f2/85/2c6867212df93b8a688c4a2645a2cfaae6ee1c875f69f98de1af2db5d3ba/aiobungie-0.2.11.tar.gz",
    "platform": null,
    "description": "# aiobungie\n\nA statically typed, asynchronous API wrapper for building clients for Bungie's API in Python.\n\n## Installing\n\nCurrently Python 3.10, 3.11 and 3.12 are supported.\n\nStable release.\n\n```sh\npip install aiobungie\n```\n\nDevelopment via github master.\n\n```sh\npip install git+https://github.com/nxtlo/aiobungie@master\n```\n\n## Quick Example\n\nSee [Examples for advance usage.](https://github.com/nxtlo/aiobungie/tree/master/examples)\n\n```py\nimport aiobungie\n\nclient = aiobungie.Client('YOUR_API_KEY')\n\nasync def main() -> None:\n    # Fetch a Destiny 2 character passing a component.\n    # This includes Equipments, Inventory, Records, etc.\n    async with client.rest:\n        my_warlock = await client.fetch_character(\n            member_id=4611686018484639825,\n            membership_type=aiobungie.MembershipType.STEAM,\n            character_id=2305843009444904605,\n            components=[aiobungie.ComponentType.CHARACTER_EQUIPMENT],\n        )\n        # Other components will be populated when passed to `components=[...]`\n        # Otherwise will be `None`\n\n        # Make sure the component is fetched.\n        assert my_warlock.equipment is not None\n\n        # Get the first item equipped on this character.\n        item = my_warlock.equipment[0]\n        print(item.hash, item.location)\n\n        # Fetch this item, Note that this performs an HTTP request.\n        # Alternatively, You can use the manifest here instead.\n        # See examples folder for more information.\n        item = await client.fetch_inventory_item(item.hash)\n        print(item.name, item.type_and_tier_name)\n        # Prints: Izanagi's Burden Exotic Sniper Rifle\n\n# You can either run it using the client or just asyncio.run(main())\nclient.run(main())\n```\n\n## RESTful clients\n\naiobungie also provides a stand-alone `RESTClient` / `RESTPool` which's what `Client` built on top of, These clients just provide a lower-level abstraction.\n\nA key note is that any `Client` based user can access the `RESTClient` instance bound to it with `.rest` property.\n\n### Key Features\n\n* Lower level, allows to read and deserialize the JSON objects yourself.\n* `RESTClient`s do not turn response payloads into one of `aiobungie.crates` object.\n* RESTful, You can use this as your REST API client in backend directly.\n* Both `Manifest` and `OAuth` methods are usable directly.\n\n### Example\n\n```py\nimport aiobungie\nimport asyncio\n\n# Single REST client connection.\nclient = aiobungie.RESTClient(\"...\")\n\nasync def main() -> None:\n    async with client:\n        # Download and open the JSON manifest.\n        manifest = await client.download_json_manifest(name=\"latest_manifest\")\n        with manifest.open(\"r\") as file:\n            data = file.read()\n\n        # OAuth2 API. 2 simple methods for fetching and refreshing tokens.\n        tokens = await client.fetch_oauth2_tokens('code')\n        refreshed_tokens = await client.refresh_access_token(tokens.refresh_token)\n\n        # Testing your own requests.\n        response = await client.static_request(\n            \"GET\", # Method.\n            \"Destiny2/path/to/route\", # Route.\n            auth=\"optional_access_token\", # If the method requires OAuth2.\n            json={\"some_key\": \"some_value\"} # If you need to pass JSON data.\n        )\n\nasyncio.run(main())\n```\n\n## Dependancies\n\n* aiohttp\n* attrs\n* `backports.datetime_fromisoformat`, required for `Python 3.10` only.\n\n### Features\n\naiobungie features are extra dependencies that replaces the standard library with either faster/neater pkgs.\n\n* `speedup`\nThis will include and uses [orjson](https://github.com/ijl/orjson) or [ujson](https://github.com/ultrajson/ultrajson)\nas the default `json` parser. They provide faster json serialization and de-serialization than the standard Python JSON pkg.\n* `full`: This will include all of the features above.\n\nFor installing the specified feature, type `pip install aiobungie[feature-name]`\n\n## Contributing\n\nPlease read this [manual](https://github.com/nxtlo/aiobungie/blob/master/CONTRIBUTING.md)\n\n## Related Projects\n\nIf you have used aiobungie and want to show your work, Feel free to Open a PR including it.\n\n* [Fated](https://github.com/nxtlo/Fated/blob/master/core/components/destiny.py): A Discord BOT that uses aiobungie.\n\n## Useful Resources\n\n* Discord Username: `vfate`\n* aiobungie Documentation: [Here](https://nxtlo.github.io/aiobungie/).\n* BungieAPI Discord: [Here](https://discord.gg/vP7VC7TKUG)\n* Official Bungie Documentation: [Here](https://bungie-net.github.io/multi/index.html)\n* Bungie Developer Portal: [Here](https://www.bungie.net/en/Application)\n\n### Additional information\n\nIf you have any question you can either open a blank issue, open a new github discussion, or just tag me in BungieAPI discord server.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python and Asyncio API wrapper for Bungie's API.",
    "version": "0.2.11",
    "project_urls": {
        "Homepage": "https://github.com/nxtlo/aiobungie",
        "Repository": "https://github.com/nxtlo/aiobungie"
    },
    "split_keywords": [
        "async",
        "api",
        "destiny",
        "bungie"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aa870b335bfcbf5cda8f1ea9aec5428cc016b53ef27c48d4f5d74ed19742117c",
                "md5": "d5b6129dde246aa18511a3fc20dcc21f",
                "sha256": "9f3bf88213859e58b1238b2e199baf2e6e4dc0bb5cdcc0fdd2989cdf456f2d98"
            },
            "downloads": -1,
            "filename": "aiobungie-0.2.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d5b6129dde246aa18511a3fc20dcc21f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10.0,<3.13",
            "size": 148775,
            "upload_time": "2024-02-05T17:17:29",
            "upload_time_iso_8601": "2024-02-05T17:17:29.676174Z",
            "url": "https://files.pythonhosted.org/packages/aa/87/0b335bfcbf5cda8f1ea9aec5428cc016b53ef27c48d4f5d74ed19742117c/aiobungie-0.2.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f2852c6867212df93b8a688c4a2645a2cfaae6ee1c875f69f98de1af2db5d3ba",
                "md5": "a9d191c92078e3f39209fb7f72879413",
                "sha256": "c283f32671b851fedf9b781bab44cef785dbe3c8206bbf7e9c81a431597838bd"
            },
            "downloads": -1,
            "filename": "aiobungie-0.2.11.tar.gz",
            "has_sig": false,
            "md5_digest": "a9d191c92078e3f39209fb7f72879413",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10.0,<3.13",
            "size": 113944,
            "upload_time": "2024-02-05T17:17:31",
            "upload_time_iso_8601": "2024-02-05T17:17:31.672873Z",
            "url": "https://files.pythonhosted.org/packages/f2/85/2c6867212df93b8a688c4a2645a2cfaae6ee1c875f69f98de1af2db5d3ba/aiobungie-0.2.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-05 17:17:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "nxtlo",
    "github_project": "aiobungie",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "aiobungie"
}
        
Elapsed time: 0.23896s