Quickstart
Every Client method is synchronous: it blocks until the node answers.
There is nothing to await.
Connect
Section titled “Connect”from calimero_client_py import Client, CloudError, SoftPasskey
# A development cluster serves mock quotes; production nodes are pinned to a# signed mero-tee release instead (tee_profiles=[...]).client = Client("http://127.0.0.1:2428", allow_mock=True)The constructor does not contact the node. The first request fetches the
node’s attestation, verifies it against the policy and opens the sealed
channel. If the node fails the check, the request raises CloudError with
status 0. For a Calimero Cloud cluster, Client.connect("cluster-name")
finds its nodes in the node directory.
Sign in
Section titled “Sign in”Scripts and tests against development clusters use an in-memory passkey:
passkey = SoftPasskey() # rp_id="localhost", origin="http://localhost:3000"client.sign_up(passkey, "alice")client.use_passkey(passkey) # answers every later step-upprint(client.auth.me().account_id)Services use an API key instead:
made = client.auth.apikey_create(label="ci", ttl_secs=86400) # approved with the passkeyservice = Client("http://127.0.0.1:2428", allow_mock=True)service.use_api_key(made.key)Deploy and call
Section titled “Deploy and call”Every route is a method of a group: client.packages, client.apps,
client.orgs, and so on (the method reference lists
them all). Arguments are keyword-only, and each method returns the generated
model of the node’s answer.
wasm = open("kv_store.wasm", "rb").read()bundle = client.packages.bundle_put(body=wasm).hash_app = client.apps.create(name="kv", bundle=bundle).app_id
r = client.apps.call(app=app, method="set", args={"key": "a", "value": "1"}, idempotency_key="k1")print(r.index, r.result)
print(client.apps.view(app=app, method="get", args={"key": "a"}).result)
for e in client.events(app, start=0, limit=10, timeout=5): print(e["id"], e["kind"], e["data"])Handle errors
Section titled “Handle errors”try: client.apps.get(app="no-such-app")except CloudError as e: message, status, code, details = e.args print(status, code)Next: using the client covers arguments, step-ups, answers and the flows that are not single routes. If you used 0.9 or 1.0.0rc3, read the migration guide.