API

class ogmios.Block(blocktype: Types, **kwargs)

Bases: object

Represents a block in the blockchain.

Parameters:
  • blocktype (ogmios.model.model_map.Types) – The type of the block (EBB, BFT, or Praos)

  • kwargs – Additional arguments depending on the block type.

Raises:

InvalidBlockParameter – If an unsupported block type is provided.

class ogmios.Client(host: str = 'localhost', port: int = 1337, secure: bool = False, http_only: bool = False, compact: bool = False, rpc_version: Jsonrpc = Jsonrpc.field_2_0)

Bases: object

Ogmios connection client

A subset of Ogmios functions require the use of WebSockets. Therefore a WebSocket connection is preferred over HTTP. If http_only is set to True, functions that require WebSockets will not be available.

If secure is set to False, ws / http will be used rather than wss / https

Parameters:
  • host (str) – The host of the Ogmios server

  • port (int) – The port of the Ogmios server

  • secure (bool) – Use secure connection

  • http_only (bool) – Use HTTP connection

  • compact (bool) – Use compact connection

  • rpc_version (Jsonrpc) – The JSON-RPC version to use

receive() dict

Receive a response from the Ogmios server

Returns:

Request response

send(request: str) None

Send a request to the Ogmios server

Parameters:

request (str) – The request to send

class ogmios.FindIntersection(client: Client)

Bases: object

Ogmios method to find a point on the blockchain. The first point that is found in the provided list will be returned.

NOTE: This class is not intended to be used directly. Instead, use the Client.find_intersection method.

Parameters:

client (Client) – The client to use for the request.

execute(points: list[Point | Origin], id: Any | None = None)

Send and receive the request.

Parameters:
  • points (list[Point | Origin]) – The list of points to find.

  • id (Any) – The ID of the request.

Returns:

The intersection, tip, and ID of the response.

Return type:

(Point | Origin, Tip | Origin, Optional[Any])

receive()

Receive the response.

Returns:

The intersection, tip, and ID of the response.

Return type:

(Point | Origin, Tip | Origin, Optional[Any])

send(points: list[Point | Origin], id: Any | None = None) None

Send the request.

Parameters:
  • points (list[Point | Origin]) – The list of points to find.

  • id (Any) – The ID of the request.

class ogmios.NextBlock(client: Client)

Bases: object

Ogmios method to request the next block in the blockchain.

Parameters:

client (Client) – The client to use for the request.

execute(id: Any | None = None)

Send and receive the request.

Parameters:

id (Any) – The ID of the request.

Returns:

The direction, tip, point or block or origin, and ID of the response.

Return type:

(Direction, Tip, Point | Origin | Block, Optional[Any])

receive()

Receive a previously requested response.

Returns:

The direction, tip, point or block or origin, and ID of the response.

Return type:

(Direction, Tip, Point | Origin | Block, Optional[Any])

send(id: Any | None = None) None

Send the request.

Parameters:
  • jsonrpc (Jsonrpc) – The JSON-RPC version to use.

  • method (Method) – The method to use.

  • id (Any) – The ID of the request.

class ogmios.Origin

Bases: object

A class representing the origin of the blockchain.

The origin is the first block in the blockchain. It is the only block that does not have a parent block.

class ogmios.Point(slot: int, id: str)

Bases: object

A class representing a point in the blockchain.

Parameters:
  • slot (int) – The slot number of the point.

  • id (str) – The block hash of the point.

class ogmios.Tip(slot: int, id: str, height: int)

Bases: object

A class representing the tip of the blockchain.

Parameters:
  • slot (int) – The slot number of the tip.

  • id (str) – The block hash of the tip.

  • height (int) – The block height of the tip.

to_point() Point

Returns a Point representation of the Tip