Metadata-Version: 2.4
Name: jnap
Version: 0.1.0
Summary: Async Python client for the Linksys JNAP API
Project-URL: Repository, https://github.com/jmalcic/jnap
Project-URL: Bug Tracker, https://github.com/jmalcic/jnap/issues
Author-email: Justin Malčić <j.malcic@me.com>
License-Expression: MIT
License-File: LICENSE
Keywords: aiohttp,async,home-automation,jnap,linksys,router
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Home Automation
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.12
Requires-Dist: aiohttp>=3.9
Description-Content-Type: text/markdown

# jnap

Async Python client for the [Linksys JNAP API](http://linksys.com/jnap/).

## Installation

```
pip install jnap
```

## Usage

```python
import asyncio
import aiohttp
from jnap import JNAPClient

async def main():
    async with aiohttp.ClientSession() as session:
        client = JNAPClient("192.168.1.1", session, password="your-password")

        info = await client.get_device_info()
        print(info.description, info.serial_number)

        response = await client.get_devices()
        for device in response.devices:
            print(device.name, device.mac, device.ip_address)

asyncio.run(main())
```

## API

### `JNAPClient(host, session, password, *, username="admin")`

The main client class. Accepts an existing `aiohttp.ClientSession` so you can manage connection pooling and lifecycle yourself.

#### Methods

- `await client.get_device_info()` → `GetDeviceInfoResponse`  
  Returns the router's description and serial number.

- `await client.get_devices()` → `GetDevicesResponse`  
  Returns all devices currently connected to the router. Only devices with a known MAC address and an active connection are included.

### Models

| Class | Fields |
|---|---|
| `GetDeviceInfoResponse` | `description`, `serial_number` |
| `GetDevicesResponse` | `devices: list[JNAPDevice]` |
| `JNAPDevice` | `mac`, `name`, `ip_address`, `hostname` |

Device names are resolved in priority order: user-assigned name → friendly name → device ID.

### Exceptions

All exceptions inherit from `JNAPError`.

| Exception | Raised when |
|---|---|
| `JNAPUnauthorizedError` | Authentication failed |
| `JNAPUnknownActionError` | The device does not recognise the action |
| `JNAPInvalidInputError` | The request was rejected as invalid |

## License

MIT
