Port1900: Async Nex Protocol Client Library
Port1900 is an async-first, fully type-hinted Python client library for the Nex protocol.
Features
- Async First: Built on top of Python's standard
asyncionetworking loop. - Nex Protocol Support: Connection management, path transmission, stateless retrieval, and directory detection.
- Type Safe: Fully typed API passing strict static type checking (
mypy --strict). - NexURI Representation: Rich URI class to parse, inspect, validate, manipulate, and resolve Nex URIs.
- Zero Dependencies: Built entirely on Python's standard library.
- CLI Utility: Includes a
port1900command-line interface out of the box.
Installation
port1900 requires Python 3.12 or later and can be installed with your package manager of choice.
With pip:
pip install port1900
With uv:
uv add port1900
Quick Start
1. Make a Simple Request
Use Client with standard async context managers to query a Nex server:
import asyncio
from port1900 import Client, Port1900Error
async def main():
async with Client() as client:
try:
# Query a Nex document or directory
response = await client.request("nex://nex.nightfall.city/")
print(f"Target host: {response.uri.host}")
print(f"Is directory: {response.is_directory}")
print(f"Content length: {len(response.content)} bytes")
print("--- Response Text ---")
print(response.text)
except Port1900Error as error:
print(f"Request failed: {error}")
if __name__ == "__main__":
asyncio.run(main())
2. Working with NexURI
The NexURI class parses full URI strings (nex://host/path) or path targets:
from port1900 import NexURI
# Parse from Nex URI string
uri = NexURI.from_string("nex://nex.nightfall.city/hello-world.txt")
print(uri.host) # 'nex.nightfall.city'
print(uri.port) # 1900
print(uri.path) # '/hello-world.txt'
print(uri.request_path) # 'hello-world.txt'
print(uri.is_directory) # False
# Create modified copies
custom_port_uri = uri.with_port(1905)
parent_uri = uri.parent
root_uri = uri.root
Command Line Interface (CLI)
port1900 includes a command-line client:
# Query a Nex target (defaults to nex://nex.nightfall.city/)
uv run port1900 nex://nex.nightfall.city/
# Query on a custom port
uv run port1900 -p 1905 nex://example.com/hello-world.txt
# Output raw binary content to stdout
uv run port1900 -r nex://nex.nightfall.city/image.png
# Display CLI help
uv run port1900 --help
Licence
MIT
Release files for port1900 1.0.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 | |
|---|---|---|---|
| port1900-1.0.0.tar.gz | 8.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| port1900-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.3 kB
Release files / port1900-1.0.0.tar.gz
| Download URL | port1900-1.0.0.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
86acdf5070e5ee8abb878d41ce55d1b48dd521efca591fed54b869415991e115
|
|
BLAKE2b-256 checksum How to use checksums |
a2d541ab19e81cef480540619eaffdd22e17467635c7a95e36b7856d68cd6b86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / port1900-1.0.0-py3-none-any.whl
| Download URL | port1900-1.0.0-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cd51649c71effe64ac30f2b29e1b852b5d08585ec7c0c3523d35478ab9f67333
|
|
BLAKE2b-256 checksum How to use checksums |
bdba8caf35c5e38fcfb606a81ec5864383e4b9ed2886139614431885414e00fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|