Metadata-Version: 2.4
Name: hexway-hive-api
Version: 0.4.0
Summary: API wrapper for Hexway Hive
Author-email: Cur1iosity <cur1iosity@protonmail.com>
Project-URL: Homepage, https://github.com/Cur1iosity/hexway-hive-api
Project-URL: Documentation, https://github.com/Cur1iosity/hexway-hive-api/blob/main/docs/methods.md
Project-URL: Changelog, https://github.com/Cur1iosity/hexway-hive-api/blob/main/CHANGELOG.md
Project-URL: Issues, https://github.com/Cur1iosity/hexway-hive-api/issues
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic>=2.4.0
Requires-Dist: aiohttp>=3.9.0
Requires-Dist: synchronicity<0.13,>=0.12.7
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Requires-Dist: pyyaml>=6; extra == "dev"
Requires-Dist: openapi-schema-validator>=0.6; extra == "dev"
Requires-Dist: synchronicity[compile]<0.13,>=0.12.7; extra == "dev"
Requires-Dist: mypy>=1.10; extra == "dev"
Dynamic: license-file

<div align="center">

# Hexway Hive API

[![Tests](https://img.shields.io/github/actions/workflow/status/Cur1iosity/hexway-hive-api/run-tests.yml?branch=main&event=push&label=tests)](https://github.com/Cur1iosity/hexway-hive-api/actions/workflows/run-tests.yml)
[![PyPI](https://img.shields.io/pypi/v/hexway-hive-api)](https://pypi.org/project/hexway-hive-api/)
[![Python](https://img.shields.io/pypi/pyversions/hexway-hive-api)](https://pypi.org/project/hexway-hive-api/)
[![License](https://img.shields.io/github/license/Cur1iosity/hexway-hive-api)](https://github.com/Cur1iosity/hexway-hive-api/blob/main/LICENSE)
[![Downloads](https://static.pepy.tech/badge/hexway-hive-api)](https://pepy.tech/projects/hexway-hive-api)
[![Last commit](https://img.shields.io/github/last-commit/Cur1iosity/hexway-hive-api/main)](https://github.com/Cur1iosity/hexway-hive-api/commits/main/)

</div>

**Hexway Hive API** is an unofficial Python client for the Hexway Hive REST API.
It has an asynchronous client (`aiohttp`) and a blocking client with exactly the same methods for working
with projects, issues, files and users, so you can automate Hive from your own scripts or async applications.
The blocking `RestClient` is the async implementation wrapped with
[synchronicity](https://github.com/modal-labs/synchronicity): one implementation, two interfaces.

Tested on Hexway Hive 2026.11.1.

## Installation
```bash
pip install hexway-hive-api
```

Requires Python 3.11 or newer. Version 0.4.0 dropped Python 3.9 and 3.10, which have reached
end of life; use 0.3.1 on those.

## Usage
### Synchronous client
```python
from hexway_hive_api import RestClient


def main() -> None:
    auth = {
        "server": "https://hive.example.com/",
        "username": "someuser",
        "password": "somepassword",
    }
    with RestClient().connection(**auth) as client:
        projects = client.get_projects().get("items")
        client.update_project(project_id=1, fields={"name": "New Project Name"})


if __name__ == "__main__":
    main()
```

### Asynchronous client
```python
import asyncio
from hexway_hive_api import AsyncRestClient


async def main() -> None:
    auth = {
        "server": "https://hive.example.com/",
        "username": "someuser",
        "password": "somepassword",
    }
    async with AsyncRestClient().connection(**auth) as client:
        projects = (await client.get_projects()).get("items")
        await client.update_project(project_id=1, fields={"name": "New Project Name"})


asyncio.run(main())
```

All methods, their arguments and what Hive returns: [docs/methods.md](https://github.com/Cur1iosity/hexway-hive-api/blob/main/docs/methods.md).

### TLS configuration

Certificate verification is on by default. `verify=False` (in the constructor or
`connect`) turns it off explicitly; TLS encryption stays on. `cert="client.pem"` or
`cert=("client.crt", "client.key")` sets a client certificate. Both work the same
for `RestClient` and `AsyncRestClient`.

### Upgrading from 0.3

0.4 runs both clients on one async implementation. Most scripts keep working;
check these points (all changes: [CHANGELOG.md](https://github.com/Cur1iosity/hexway-hive-api/blob/main/CHANGELOG.md)):

- **Python 3.11+.**
- `RestClient` is `AsyncRestClient` made blocking (no more `requests`). It now has
  `get_project_pages_metadata` and `get_project_page_metadata` too.
- **Errors:** HTTP errors raise `HiveRestError` (`status_code`, `body`, `title`,
  `detail`, ...), network errors `TransportError`, invalid JSON `ProtocolError`.
  All three are `ClientError`s, so `except ClientError` still works. A refused
  login raises `AuthenticationError`, an MFA-protected account `MfaRequiredError`
  (both `RestConnectionError`s). `get_users()` no longer turns HTTP errors into
  `RestConnectionError`. Requests before `connect()` raise `ClientNotConnected`.
  Exceptions of `requests` (`requests.exceptions.ConnectionError`, ...) no longer
  appear: an unreachable server raises `RestConnectionError` in `connect()` and
  `TransportError` elsewhere.
- `connect()` needs both `username` and `password`.
- `get_file()` always returns `bytes`, also for JSON files.
- `RestClient().http_client` and `hexway_hive_api.rest.HTTPClient` are gone;
  `rest/error_handler.py` (unused) is removed. Extra constructor arguments go to
  `aiohttp.ClientSession`; SOCKS proxies are not supported.

## Development

```bash
pip install -e ".[dev]"
pytest
```

Tests run without a Hive server. Requests the library sends are checked against
the Hive OpenAPI contract in `contracts/`, which is extracted from the official
offline installer. See [docs/testing.md](https://github.com/Cur1iosity/hexway-hive-api/blob/main/docs/testing.md) for the whole workflow
and for what to do when a new Hive version comes out.

## API coverage

![API coverage by library version](https://raw.githubusercontent.com/Cur1iosity/hexway-hive-api/coverage-assets/coverage.svg)

See [api_coverage_info/COVERAGE.md](https://github.com/Cur1iosity/hexway-hive-api/blob/main/api_coverage_info/COVERAGE.md) for what is covered,
by API section, and what is not yet.

## License

MIT, see [LICENSE](https://github.com/Cur1iosity/hexway-hive-api/blob/main/LICENSE).
