Skip to main content

Hittade Client

A Python HTTP client library for the Hittade API, providing both synchronous and asynchronous interfaces with full type safety.

Features

  • 🔄 Both synchronous and asynchronous clients
  • 🔒 Full type safety with Pydantic models
  • ✅ Comprehensive test coverage (42 tests, 100% passing)
  • 🔐 BasicAuth authentication support
  • 📄 Built-in pagination helpers
  • 🎯 Clean, minimal API
  • 📦 Context manager support for automatic cleanup

Installation

pip install hittade-client

Or with uv:

uv pip install hittade-client

Quick Start

Synchronous Client

from hittade_client import HittadeClient

# Basic usage
with HittadeClient(base_url="https://api.example.com") as client:
    # List all hosts
    hosts = client.list_hosts(limit=100)
    for host in hosts.items:
        print(f"{host.id}: {host.hostname}")
    
    # Paginate through all hosts
    page = client.list_hosts(limit=50)
    while page is not None:
        for host in page.items:
            print(f"{host.id}: {host.hostname}")
        page = client.next_page(page)
    
    # Get host configuration
    config = client.get_host_config("host-123")
    for entry in config:
        print(f"{entry.ctype}: {entry.name} = {entry.value}")
    
    # Get detailed host information
    details = client.get_host_details("host-123")
    print(f"OS: {details.details.osname} {details.details.osrelease}")
    print(f"IP: {details.details.ipv4}")
    print(f"Packages: {len(details.packages)}")
    print(f"Containers: {len(details.containers)}")

Asynchronous Client

from hittade_client import AsyncHittadeClient

async def main():
    async with AsyncHittadeClient(base_url="https://api.example.com") as client:
        # List hosts
        hosts = await client.list_hosts(limit=100)
        
        # Paginate through all hosts
        page = await client.list_hosts(limit=50)
        while page is not None:
            for host in page.items:
                print(f"{host.id}: {host.hostname}")
            page = await client.next_page(page)
        
        # Get host configuration
        config = await client.get_host_config("host-123")
        
        # Get detailed host information
        details = await client.get_host_details("host-123")

Authentication

from hittade_client import HittadeClient, BasicAuth

# With BasicAuth
auth = BasicAuth(username="your-username", password="your-password")

with HittadeClient(base_url="https://api.example.com", auth=auth) as client:
    hosts = client.list_hosts()

Custom Configuration

from hittade_client import HittadeClient, BasicAuth

client = HittadeClient(
    base_url="https://api.example.com",
    timeout=60.0,  # Request timeout in seconds
    headers={"X-Custom-Header": "value"},  # Custom headers
    follow_redirects=True,  # Follow HTTP redirects
    auth=BasicAuth(username="user", password="pass"),  # BasicAuth
)

# Use the client
hosts = client.list_hosts(limit=50, offset=100)

# Don't forget to close when not using context manager
client.close()

API Reference

Client Methods

list_hosts(limit=500, offset=0)

List hosts with pagination.

Parameters:

  • limit (int): Maximum number of results (default: 500, minimum: 1)
  • offset (int): Offset for pagination (default: 0, minimum: 0)

Returns: PagedHostSchema with items (list of hosts), count (total count), limit, and offset

next_page(paged_data)

Get the next page of hosts based on current page data.

Parameters:

  • paged_data (PagedHostSchema): Current page data from list_hosts()

Returns: PagedHostSchema for the next page, or None if no more results

Example:

page = client.list_hosts(limit=50)
while page is not None:
    # Process page.items
    page = client.next_page(page)

get_host_config(host_id)

Get host configuration entries.

Parameters:

  • host_id (str): The host identifier

Returns: List of HostConfigurationSchema objects

get_host_details(host_id)

Get complete host details including OS information, network configuration, packages, and containers.

Parameters:

  • host_id (str): The host identifier

Returns: CombinedHostSchema with all host details

Models

BasicAuth

  • username (str): Username for authentication
  • password (str): Password for authentication

HostSchema

  • id (str): Host identifier
  • hostname (str): Host hostname

PagedHostSchema

  • items (list[HostSchema]): List of hosts
  • count (int): Total count of hosts
  • limit (int): Limit used in request
  • offset (int): Offset used in request

HostConfigurationSchema

  • ctype (str): Configuration type
  • name (str): Configuration name
  • value (str): Configuration value

HostDetailsSchema

  • time (datetime): Timestamp
  • domain (str | None): Domain name
  • osname (str): Operating system name
  • osrelease (str): Operating system release
  • rkr (str): RKR value
  • cosmosrepourl (str): Cosmos repository URL
  • ipv4 (str | None): IPv4 address
  • ipv6 (str | None): IPv6 address
  • fail2ban (bool): Fail2ban status

PackageSchema

  • id (int): Package identifier
  • name (str): Package name
  • version (str): Package version

ServerContainerSchema

  • image (str): Container image name
  • imageid (str): Container image ID

CombinedHostSchema

  • host (HostSchema): Basic host information
  • details (HostDetailsSchema): Detailed host information
  • packages (list[PackageSchema]): Installed packages
  • containers (list[ServerContainerSchema]): Running containers
  • configs (list[HostConfigurationSchema]): Configuration entries

Exceptions

HittadeError

Base exception for all Hittade client errors.

HittadeAPIError

Raised when the API returns an HTTP error (4xx, 5xx status codes).

HittadeValidationError

Raised when response validation fails (invalid response data from API).

Development

Setup

# Install dependencies
uv sync

# Install in editable mode
uv pip install -e .

Running Tests

# Run all tests
make test

# Run with pytest directly
uv run pytest tests/ -v

Code Formatting

# Format and lint code
make reformat

Type Checking

# Run mypy type checker
make typecheck

Building Package

# Build distribution packages (wheel and source)
make build

# Clean build artifacts
make clean

Requirements

  • Python 3.11 or higher
  • httpx >= 0.28.1
  • pydantic >= 2.12.1

License

This project is licensed under the BSD 2-Clause License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Metadata

Release files for hittade-client 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hittade-client 0.1.2
File Size Uploaded
hittade_client-0.1.2.tar.gz 30.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hittade-client 0.1.2
File Interpreter ABI Platform
hittade_client-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 39.2 kB

Release files / hittade_client-0.1.2.tar.gz

Download URL hittade_client-0.1.2.tar.gz
Size 30.9 kB
Tags Source
SHA-256 checksum
How to use checksums
30bdca44ecd28b8124568ae13c639da875cc3ec8e40e0f8b4bd4da3158f395bc
BLAKE2b-256 checksum
How to use checksums
81d4ab3639ec36108a1a78ad87b0478c4a765137897de64413b41db546d2cd12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 12, 2025.

Transparency log

Release files / hittade_client-0.1.2-py3-none-any.whl

Download URL hittade_client-0.1.2-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
edde669f85a88adba3981bf2a8b2658e6b212ede7d1d05bda60e5a7993a08217
BLAKE2b-256 checksum
How to use checksums
d1af2d8b0e68f317cb245224186e3b1c7195838bd20c92eab9da300634eedf89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 12, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page