Metadata-Version: 2.4
Name: skyhelper-networth
Version: 0.0.1a0
Summary: SkyHelper's Networth Calculation for Hypixel SkyBlock rewritten in Python
Author: Zalko
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Dist: aiohttp~=3.13
Requires-Dist: amulet-mutf8~=1.0
Requires-Python: >=3.13
Project-URL: homepage, https://codeberg.org/Zalko/SkyHelper-Networth-Python
Project-URL: issues, https://codeberg.org/Zalko/SkyHelper-Networth-Python/issues
Project-URL: repository, https://codeberg.org/Zalko/SkyHelper-Networth-Python
Description-Content-Type: text/markdown

# SkyHelper-Networth-Python

[![stars](https://img.shields.io/gitea/stars/Zalko/SkyHelper-Networth-Python?gitea_url=https://codeberg.org&style=for-the-badge&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEiIHZpZXdCb3g9IjAgMCAxNiAxNiIgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2Ij48cGF0aCBkPSJNOCAuMjVhLjc1Ljc1IDAgMCAxIC42NzMuNDE4bDEuODgyIDMuODE1IDQuMjEuNjEyYS43NS43NSAwIDAgMSAuNDE2IDEuMjc5bC0zLjA0NiAyLjk3LjcxOSA0LjE5MmEuNzUxLjc1MSAwIDAgMS0xLjA4OC43OTFMOCAxMi4zNDdsLTMuNzY2IDEuOThhLjc1Ljc1IDAgMCAxLTEuMDg4LS43OWwuNzItNC4xOTRMLjgxOCA2LjM3NGEuNzUuNzUgMCAwIDEgLjQxNi0xLjI4bDQuMjEtLjYxMUw3LjMyNy42NjhBLjc1Ljc1IDAgMCAxIDggLjI1bTAgMi40NDVMNi42MTUgNS41YS43NS43NSAwIDAgMS0uNTY0LjQxbC0zLjA5Ny40NSAyLjI0IDIuMTg0YS43NS43NSAwIDAgMSAuMjE2LjY2NGwtLjUyOCAzLjA4NCAyLjc2OS0xLjQ1NmEuNzUuNzUgMCAwIDEgLjY5OCAwbDIuNzcgMS40NTYtLjUzLTMuMDg0YS43NS43NSAwIDAgMSAuMjE2LS42NjRsMi4yNC0yLjE4My0zLjA5Ni0uNDVhLjc1Ljc1IDAgMCAxLS41NjQtLjQxeiIgZmlsbD0iI2ZmZiIvPjwvc3ZnPg==)
](https://codeberg.org/Zalko/SkyHelper-Networth-Python)
[![license](https://img.shields.io/badge/license-MIT-green?style=for-the-badge&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEiIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTguNzUuNzVWMmguOTg1Yy4zMDQgMCAuNjAzLjA4Ljg2Ny4yMzFsMS4yOS43MzZjLjAzOC4wMjIuMDguMDMzLjEyNC4wMzNoMi4yMzRhLjc1Ljc1IDAgMCAxIDAgMS41aC0uNDI3bDIuMTExIDQuNjkyYS43NS43NSAwIDAgMS0uMTU0LjgzOGwtLjUzLS41My41MjkuNTMxLS4wMDEuMDAyLS4wMDIuMDAyLS4wMDYuMDA2LS4wMDYuMDA1LS4wMS4wMS0uMDQ1LjA0Yy0uMjEuMTc2LS40NDEuMzI3LS42ODYuNDVDMTQuNTU2IDEwLjc4IDEzLjg4IDExIDEzIDExYTQuNDk4IDQuNDk4IDAgMCAxLTIuMDIzLS40NTQgMy41NDQgMy41NDQgMCAwIDEtLjY4Ni0uNDVsLS4wNDUtLjA0LS4wMTYtLjAxNS0uMDA2LS4wMDYtLjAwNC0uMDA0di0uMDAxYS43NS43NSAwIDAgMS0uMTU0LS44MzhMMTIuMTc4IDQuNWgtLj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version-toml?tomlFilePath=https://codeberg.org/Zalko/SkyHelper-Networth-Python/raw/branch/main/pyproject.toml&style=for-the-badge&logoColor=white&logo=python)
](pyproject.toml)

[SkyHelper](https://skyhelper.altpapier.dev/)'s Networth Calculation as a Python package to
calculate a player's SkyBlock networth by using their profile data provided by
the [Hypixel API](https://api.hypixel.net/).

> [!NOTE]
> This project is not affiliated with SkyHelper or Hypixel in any way.
> Do not report issues regarding this package to them.
> However, feel free to open an
> issue [here](https://codeberg.org/Zalko/SkyHelper-Networth-Python/issues).

## Installation

You can install the package using pip:

```bash
pip install git+https://codeberg.org/Zalko/SkyHelper-Networth-Python.git
```

Or using uv:

```bash
uv add git+https://codeberg.org/Zalko/SkyHelper-Networth-Python.git
```

## Quick Start

This package was designed to be used asynchronously, you should use an async HTTP client to fetch
the profile and museum data from the Hypixel API. It
uses [aiohttp](https://github.com/aio-libs/aiohttp) internally to make its API calls (to get current
prices from SkyHelper prices repo and item information from Hypixel API). The following example
demonstrates how to use the `ProfileNetworthCalculator` to calculate a player's networth while
reusing the existing `ClientSession`:

```python
import asyncio

from aiohttp import ClientSession

from skyhelper_networth import ProfileNetworthCalculator

uuid = ""
profile_id = ""
hypixel_api_key = ""
headers = {"API-Key": hypixel_api_key}


async def main():
    async with ClientSession() as session:
        async with session.get(f"https://api.hypixel.net/v2/skyblock/profiles?uuid={uuid}", headers=headers) as response:
            profiles = await response.json()
        async with session.get(f"https://api.hypixel.net/v2/skyblock/museum?profile={profile_id}", headers=headers) as response:
            museum = await response.json()

        profile = next(profile for profile in profiles.get("profiles") if profile.get("profile_id") == profile_id)
        user_profile = profile.get("members").get(uuid)
        balance = profile.get("banking").get("balance")
        museum_data = museum.get("members").get(uuid)

        calculator = ProfileNetworthCalculator(user_profile, museum_data, balance, session=session)
        networth = await calculator.get_networth()
        non_cosmetic_networth = await calculator.get_non_cosmetic_networth()

    print("Networth:", networth)
    print("Non-Cosmetic Networth:", non_cosmetic_networth)


asyncio.run(main())
```

If you do not wish to provide a session, you can use `ProfileNetworthCalculator` as an asynchronous
context manager, which will handle the session internally. It is not recommended as it will create a
new session for each instance of the calculator.

```python
async with ProfileNetworthCalculator(user_profile, museum_data, balance) as calculator:
    networth = await calculator.get_networth()
```

> [!IMPORTANT]
> Methods like `get_networth` and `get_non_cosmetic_networth`
> will only work within the context manager or as long as the session is open.

> [!NOTE]
> Other calculators are available, such as `BasicItemCalculator` or `SkyBlockItemCalculator`,
> which can be used to calculate the networth of a single item.

## Contributing

Contributions are welcome!\
The project uses [uv](https://github.com/astral-sh/uv) for development, you can set up your
environment with:

```bash
uv sync
```

### Pre-commit Hooks

You can use [prek](https://github.com/j178/prek) for pre-commit hooks. It will notably
run [pyproject-fmt](https://pypi.org/project/pyproject-fmt/),
[Ruff](https://github.com/astral-sh/ruff) and
[ty](https://github.com/astral-sh/ty). Check out [prek.toml](prek.toml) for the full configuration.

```bash
uv run prek
```

You can install the pre-commit hooks so that it runs automatically before each commit with the
following command:

```bash
uv run prek install
```

### Testing

You can run the tests using unittest:

```bash
uv run -m unittest
```

## Credits

Huge thanks to Altpapier for
creating [SkyHelper-Networth](https://github.com/Altpapier/SkyHelper-Networth). This project would
not have been possible without their work.

I would also like to thank DuckySoLucky for doing a Go implementation of the Node.js
module, [SkyHelper-Networth-Go](https://github.com/SkyCryptWebsite/SkyHelper-Networth-Go), which
helped me understand the structure and logic of the original code. It served as a great reference to
correctly type the code.

Again, this project is not affiliated with either of them.

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

The NBT parsing code is based on [PyNBT](https://github.com/TkTech/PyNBT) by Tyler Kennedy, which is
also licensed under the MIT License.
