Skip to main content

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 asyncio networking loop.
  • Spartan Protocol Spec Compliant: Supports text/binary downloads and uploads (content-length specification), default port 300, and all status codes (2 Success, 3 Redirect, 4 Client Error, 5 Server 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 sybaritic command-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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sybaritic-0.0.2.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sybaritic-0.0.2-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file sybaritic-0.0.2.tar.gz.

File metadata

  • Download URL: sybaritic-0.0.2.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","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}

File hashes

Hashes for sybaritic-0.0.2.tar.gz
Algorithm Hash digest
SHA256 2f93c3460f1a615c5e6ed43ed5df67f1e71fa7a6709027dda80bd411379708a0
MD5 9712a14eff3608ffc6ef0676fd559178
BLAKE2b-256 1c7480df365b8a6d4d396c5b256a73cdc1d4ec166538bd17a4e4e076d7569ecd

See more details on using hashes here.

File details

Details for the file sybaritic-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: sybaritic-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","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}

File hashes

Hashes for sybaritic-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ea7e97c0532610d4dd9f82935935091b641084e46c57bfd028a96d44e4f2689d
MD5 c1da02ad23a767ba1c95c4a9fa890249
BLAKE2b-256 c031619fdfecb2126177f0fa63a59aa1f929daf0bbb6f04c827679330dea9c06

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page