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.0
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.0.tar.gz | 3.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aiohost-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.9 kB
Release files / aiohost-0.1.0.tar.gz
| Download URL | aiohost-0.1.0.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5a30245af806b0543dd698d6a6cd823acf0fe87350a6dd3c476fdb441fcd18d3
|
|
BLAKE2b-256 checksum How to use checksums |
4b49ab2d15120e04f2c4d97fbb65d71e7b54302c3248e00bf468fdd6617ac237
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / aiohost-0.1.0-py3-none-any.whl
| Download URL | aiohost-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8f70a1cc7f152e69a1c03ca3f2d20ebd0046389f501613400460079468dca1dc
|
|
BLAKE2b-256 checksum How to use checksums |
15ef22ba821a0b9eb3b4f2bb4f8934f2700f12e0c2f152b66b01c203ca54f225
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|