Skip to content

Quickstart

This page takes you from a fresh install to a working connection and a first call. It assumes you have a reachable Calimero node — either a local merod node or a remote one.

  1. Create a connection to the node’s API URL, then a client from it:

    from calimero_client_py import create_connection, create_client
    connection = create_connection(
    api_url="http://localhost:2428",
    node_name="local-dev", # stable name; used for the token cache
    )
    client = create_client(connection)
  2. Ask the node something simple:

    print("connected to", client.get_api_url())
    contexts = client.list_contexts()
    print(f"found {len(contexts)} contexts")

create_connection only validates and stores the URL; it does not open a socket. The first request the client makes (here list_contexts) is what actually reaches the node.

Once you have a context running an application, execute one of its methods over JSON-RPC. Arguments are passed as a JSON string:

result = client.execute_function(
context_id="<context-id>",
method="set",
args='{"key": "greeting", "value": "hello"}',
)
print(result)

Calls raise a ValueError for malformed inputs (an invalid ID, URL, or JSON argument) and a RuntimeError when the node call itself fails:

try:
ctx = client.get_context("not-a-real-id")
except ValueError as e:
print("bad input:", e)
except RuntimeError as e:
print("node error:", e)

See error handling for the full picture.