BACK TO PRODUCTS

Ogmios

By

By CardanoSolutions

This page provides instructions on how to interact with the Cardano Ogmios service offered by Demeter.

About Ogmios Sync

Ogmios is a lightweight bridge interface for cardano-node. It provides an HTTP / WebSocket API that enables applications to interact with a local cardano-node via JSON+RPC-2.0. Examples and documentation can be found in the GitHub repository.

Demeter Implementation

Each Demeter cluster provides highly-available, multi-tenant instances of Cardano Ogmios. Connections to these instances are load balanced. Projects can connect to the instance and receive events from ogmios.

Demeter Ogmios access will consume DCUs from your project's wallet.

Enabling Access

To enable access in your project, you need to add a Cardano Ogmios Port resource:

  1. Login to Demeter.run
  2. Select your project
  3. From your project's dashboard, click "Add Resource"
  4. Find the resource "Cardano Ogmios Port" card and select it
  5. Click "Create Resource"
  6. Select the Cardano network and version you want to access
  7. Click "Create Resource" once again

Getting Started

Once created, your Cardano Ogmios Port resource will present you with the required information to access the Ogmios instance:

  • HTTP Endpoint URL: the publicly accessible hostname of the Ogmios instance by network (eg: NETWORK-VERSION.ogmios-v1.demeter.run)
  • HTTP Authenticated Endpoint URL: the publicly accessible hostname of the Ogmios instance, but with the key set on the hostname without necessary to set it on the header. (eg: KEY.NETWORK-VERSION.ogmios-v1.demeter.run)
  • Api Key: the key to authenticating, will needs to be set on the header (eg: dmtr-api-key: dmtr_ogmios63j21khsjx)

The above value will change for each project depending on your configuration.

  • Python
  • NodeJS
  • Go

You can use a library like websockets to connect to a Ogmios instance in Python. Here's a basic example:

The key on the host not working with python, please set the key on the header(dmtr-api-key).

import asyncio
import websockets
import json

async def connect_to_websocket():
    host = "wss://mainnet-v5.ogmios-m1.demeter.run"
    headers = {
        'dmtr-api-key': 'dmtr_ogmiosXXX',
    }

    async with websockets.connect(host, extra_headers=headers) as websocket:
        print(f"Connected to {host}")

        event = {
                'jsonrpc': '2.0',
                'method': 'queryLedgerState/utxo',
                'params': {
                    'addresses': ['addrXXXX']
                }
        }

        await websocket.send(json.dumps(event))
        response = await websocket.recv()
        print(f"Received from server: {response}")

    print("WebSocket connection closed.")

asyncio.get_event_loop().run_until_complete(connect_to_websocket())

In this code, replace host, and dmtr-api-key if is necessary

This will connect and send an event to get utxos from an address

1. Select type

2. Select project