Aiohost
Simple python library to async use https://check-host.net/about/api
Features
- Fully Asynchronous: Built on top of
httpxfor non-blocking I/O. - Zero Boilerplate: No client initialization required. Just a single function call.
- Auto-Polling: Automatically waits for all nodes to complete the check and returns the final result.
- Foolproof: Strict input validation for types, ports, and check types.
Installation
Install via pip:
pip install aiohost
Or using uv:
uv add aiohost
Usage
Basic Check
The simplest way to check a host. The function will automatically initiate the check, poll the API, and return the final result.
import asyncio
from aiohost import check
async def main():
# Check TCP port 443 on google.com using 3 random nodes
result = await check("tcp", "google.com", port=443, max_nodes=3)
print(result)
if __name__ == "__main__":
asyncio.run(main())
Advanced Check (Specific Nodes)
You can specify exact nodes to use for the check.
import asyncio
from aiohost import check
async def main():
result = await check(
check_type="ping",
host="1.1.1.1",
max_nodes=2,
nodes=["us1.node.check-host.net", "de1.node.check-host.net"],
)
print(result)
if __name__ == "__main__":
asyncio.run(main())
Error Handling
The library raises standard Python exceptions for invalid inputs or API errors.
import asyncio
from aiohost import check
async def main():
try:
# This will raise a ValueError due to invalid port
await check("tcp", "google.com", port=99999)
except ValueError as e:
print(f"Validation Error: {e}")
except RuntimeError as e:
print(f"API Error: {e}")
if __name__ == "__main__":
asyncio.run(main())
API Reference
check
Initiates a check and returns the final result dictionary.
async def check(
check_type: Literal["ping", "http", "tcp", "dns", "udp"],
host: str,
port: Optional[int] = None,
max_nodes: int = 3,
max_wait: float = 30.0,
poll_interval: float = 1.5,
nodes: Optional[List[str]] = None,
) -> Dict[str, Any]
| Parameter | Type | Default | Description |
|---|---|---|---|
check_type |
str |
Required | Type of check: "ping", "http", "tcp", "dns", or "udp". |
host |
str |
Required | Target hostname or IP address. |
port |
int |
None |
Target port (required for tcp/udp, optional for others). Must be 1-65535. |
max_nodes |
int |
3 |
Number of random nodes to use for the check. |
max_wait |
float |
30.0 |
Maximum time in seconds to wait for all nodes to finish. |
poll_interval |
float |
1.5 |
Time in seconds between polling the API for results. |
nodes |
List[str] |
None |
Optional list of specific node hostnames to use (overrides max_nodes). |
License
This project is licensed under the MIT License. See the LICENSE file for details.
Release files for aiohost 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aiohost-0.1.1.tar.gz | 29.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aiohost-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 45.4 kB
Release files / aiohost-0.1.1.tar.gz
| Download URL | aiohost-0.1.1.tar.gz |
|---|---|
| Size | 29.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1d02b72b03f093d9bed46d216216b8615ab9ad38178f4e2392efc4e7f29a74c1
|
|
BLAKE2b-256 checksum How to use checksums |
2e7a887aa238d5823693ea1eedda8537277e338fd49625d8b81a83b40b6a6a18
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / aiohost-0.1.1-py3-none-any.whl
| Download URL | aiohost-0.1.1-py3-none-any.whl |
|---|---|
| Size | 16.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1899a7ac0934df786c22de072a6f97b20368a0a6ca40a27cd1ed609a6b025b83
|
|
BLAKE2b-256 checksum How to use checksums |
3bdcd7832e4c4c314fd2f03d9ee897fa6d8337879eb7a469b889bc6bef0de6a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|