Sybaritic: Async Spartan Protocol Client Library
Sybaritic is an async-first, fully type-hinted Python client library for the Spartan Protocol.
Features
- Async First: Built on top of Python's standard
asyncionetworking loop. - Spartan Protocol Spec Compliant: Supports text/binary downloads and uploads (
content-lengthspecification), default port300, and all status codes (2Success,3Redirect,4Client Error,5Server Error). - Type Safe: Fully typed API with PEP 561 compliance (
py.typed). - SpartanURI Representation: Rich URI class to parse, inspect, validate, and manipulate Spartan URIs (including punycode support for IDNs).
- Auto Redirect Handling: Automatically handles redirects (
status 3) with loop detection and max redirect threshold limits. - Zero Heavy Dependencies: Built on top of Python's standard library.
- CLI Utility: Includes a
sybariticcommand-line utility out of the box.
Installation
sybaritic requires Python 3.12 or later and can be installed with uv or pip:
With uv:
uv add sybaritic
With pip:
pip install sybaritic
Quick Start
1. Make a Simple Request
Use Client with standard async context managers to query a Spartan server:
import asyncio
from sybaritic import Client, SybariticError
async def main():
async with Client() as client:
try:
# Query a Spartan document (defaults to port 300)
response = await client.request("spartan://spartan.mozz.us/specification.gmi")
print(f"Status: {response.status} ({response.meta})")
print(f"Content Type: {response.mime_type}")
print(response.text)
except SybariticError as exc:
print(f"Error querying Spartan server: {exc}")
asyncio.run(main())
2. Upload Data to a Server
Post data to a Spartan resource:
import asyncio
from sybaritic import Client
async def main():
async with Client() as client:
# Send data payload
response = await client.post("spartan://example.com/guestbook", data="Hello Spartan!")
print(response.text)
asyncio.run(main())
Command Line Interface (CLI)
sybaritic provides a command-line interface:
# Request a resource
sybaritic spartan://spartan.mozz.us/specification.gmi
# Output headers with body
sybaritic -i spartan://spartan.mozz.us/specification.gmi
# Upload data payload
sybaritic spartan://example.com/submit "My comment text"
# Post payload from a file
sybaritic spartan://example.com/upload -f payload.txt
Running Tests
Run the test suite using uv:
uv run pytest
License
MIT License
Release files for sybaritic 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 | |
|---|---|---|---|
| sybaritic-1.0.0.tar.gz | 12.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sybaritic-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.8 kB
Release files / sybaritic-1.0.0.tar.gz
| Download URL | sybaritic-1.0.0.tar.gz |
|---|---|
| Size | 12.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5b7dec90e9618fee55de023294eefb11a7e5c441541c053d87e565acea2fbe65
|
|
BLAKE2b-256 checksum How to use checksums |
0cbaa90c561bca6d1946dc2c897c9ed797ad65a4b1a883d641b79dd8577ca33c
|
| 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 / sybaritic-1.0.0-py3-none-any.whl
| Download URL | sybaritic-1.0.0-py3-none-any.whl |
|---|---|
| Size | 14.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c01729418530cd18da82d3257b767fb7c059831222d42c7551de2d3f7921757b
|
|
BLAKE2b-256 checksum How to use checksums |
ef5cb148ee608deaff7ebef34491b33ba16b198680773a91729364414c6aea81
|
| 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}
|