Skip to main content
The groundhog-sdk package is the synchronous Python client for the Groundhog version 1 HTTP API. Version 0.2 supports Unix sockets and HTTPS. Each SDK operation maps to one public HTTP operation. Groundhog remains responsible for durability, order, idempotency, and authoritative stream state. The SDK does not provide local SQL or derived views.

Requirements

  • Python 3.10 or newer
  • A running Groundhog 0.2 service
  • Access to its Unix socket or HTTPS endpoint
  • Its bearer token when authentication is active
The SDK does not install, start, stop, or supervise Groundhog.

Installation

Install the 0.2 release from PyPI:
The PyPI distribution name is groundhog-sdk. Python code imports groundhog_sdk.

Connect through a Unix socket

The SDK accepts absolute and relative socket paths:
The default endpoint is unix:data/ground.sock.

Connect through HTTPS

The HTTPS transport uses standard certificate and hostname verification. An endpoint can include a port and base path.
Groundhog itself listens only on a Unix socket. An operator-managed HTTPS service must forward the version 1 routes.

Explicit transport settings

Use TransportConfig to keep the endpoint and timeout in one value:
Ground also reads GROUND_URL and GROUND_TOKEN. Explicit arguments take precedence over environment variables. Set these variables before you construct Ground(), then omit the matching arguments. max_retries sets the number of attempts after the first request. The default is 3. The SDK retries connection failures and HTTP 429 responses. Ingest also retries HTTP 503 responses with bounded exponential delays.

Build events

The event constructors produce the connector-owned fields:
The SDK validates names, keys, kinds, times, payloads, finite numbers, Unicode, and nesting before sending. Groundhog performs authoritative validation.

Ingest an atomic batch

send(source, events, batch_id) maps to POST /v1/events. A batch contains 1 through 10,000 events and no more than 32 MiB. The SDK encodes the complete batch once before its first attempt. A retry sends identical bytes with the same (source, batch_id).
  • committed means the request durably appended the batch.
  • duplicate means identical content already committed.
  • IdempotencyConflict means the key identifies different committed content.
Advance a source cursor only after a successful BatchReceipt.

Replay events

events() maps to one finite GET /v1/events request. It returns full events in authoritative event_id order. Filters use exact matches and after is exclusive. Persist next_after for the next finite request. EventPage contains: The 0.2 SDK returns one finite page per call. It does not provide a follow iterator or persistent cursor storage. Use the HTTP API directly when a Python application needs continuous follow.

Enumerate streams

streams() maps to GET /v1/streams. It returns typed Stream values in a StreamPage. Each row reports authoritative state from the durable log. It does not report a derived catalog snapshot. For another page, use one anchored snapshot:
Use the same source filter on each page. after requires the first page’s snapshot_through_event_id as through.

Build derived views

Groundhog stores and serves the durable event log. Applications build their own derived views from replay. A Python consumer normally applies each event and saves its event ID in the same database transaction. It can rebuild the view by replaying the log from the start. The SDK does not include a database adapter, SQL engine, or current-state model.

Errors

All SDK exceptions derive from GroundError. Remote errors expose these attributes: Use code, not message, for program control. The server can change descriptive text without changing its contract. ValidationError.errors contains indexed event errors when the server provides them. Local errors and responses from old servers can have code set to None.

Current 0.2 surface

The package exports:
Version 0.2 removes Ground.query(), Ground.catalog(), QueryResult, CatalogResult, SnapshotReceipt, and QueryError. The package does not include follow, persistent cursors, async parity, connector management, or Groundhog process supervision.