DrandApi

interface DrandApi : Closeable

Core interface for interacting with drand networks via various transport mechanisms.

This interface defines the complete drand API for fetching randomness beacons and chain information. Implementations provide different transport layers (HTTP, gRPC, etc.) while maintaining a consistent API surface.

API Organization

The API is organized into two parallel operation sets:

  • Beacon operations: Access networks by human-readable beacon ID (e.g., "default", "quicknet")

  • Chain operations: Access networks by cryptographic chain hash (hex-encoded)

Both operation sets provide identical functionality. Beacon IDs are convenient aliases that the drand API resolves to chain hashes. For maximum reliability, use chain hashes directly as they cannot be changed, whereas beacon IDs could theoretically be reassigned.

Usage

val api = DrandHttpApi()

// Using beacon ID (convenient)
val beacon = api.beacons.latest("quicknet").getOrThrow()

// Using chain hash (more explicit)
val sameBeacon = api.chains.latest(
"52db9ba70e0cc0f6eaf7803dd07447a1f5477735fd3f661792ba94600c84e971"
).getOrThrow()

See also

for HTTP/JSON transport implementation

Inheritors

Types

Link copied to clipboard

Operations for accessing drand networks by beacon ID.

Link copied to clipboard
interface ChainOperations

Operations for accessing drand networks by chain hash.

Properties

Link copied to clipboard

Operations for accessing drand networks by beacon ID.

Link copied to clipboard

Operations for accessing drand networks by chain hash.

Functions

Link copied to clipboard
expect abstract fun close()