GRID Docs

Code examples

Copy-paste snippets against the live public API. All of these are read-only unless noted.

curl — chain and upstream health

bash
curl -fsS https://grid-compute.com/api/explorer \
  | jq '{
      checkedAt,
      health,
      chain: .chain | {chainId, height, tipHash, blocks},
      rewards: .coordinator.rewards,
      settlement
    }'

curl — free capacity poller

bash
#!/usr/bin/env bash
set -euo pipefail
API=https://grid-compute.com

while true; do
  curl -fsS "$API/api/registry/computes?available=1" \
    | jq -r '.computes[]? | "\(.name)\tslots=\(.freeSlots)\t\(.class)\t\(.region // "-")"'
  sleep 3600
done

JavaScript — registry dashboard widget

javascript
const API = "https://grid-compute.com";

export async function loadRegistrySummary() {
  const [reg, mesh] = await Promise.all([
    fetch(`${API}/api/registry`).then((r) => r.json()),
    fetch(`${API}/api/mesh`).then((r) => r.json()),
  ]);

  return {
    names: (reg.entries ?? []).map((e) => e.name),
    freeSlots: reg.computeStats?.freeSlots ?? 0,
    onlinePeers: mesh.stats?.online ?? 0,
    updatedAt: reg.updatedAt,
  };
}

// Browser: safe — no secrets
const summary = await loadRegistrySummary();
console.log(summary);

Python — filter computes by class

python
import urllib.request, json

API = "https://grid-compute.com"

def get_computes(available_only=True):
    q = "?available=1" if available_only else ""
    with urllib.request.urlopen(f"{API}/api/registry/computes{q}") as res:
        return json.load(res)

data = get_computes()
for c in data.get("computes", []):
    if c.get("class") in ("M", "L") and (c.get("freeSlots") or 0) > 0:
        print(c["name"], c["freeSlots"], c.get("image"))

Name availability

bash
name=garage
curl -sS "https://grid-compute.com/api/registry/register?name=$name" | jq '{ok, available, name, reason}'

Badge check for Mesh UI

javascript
async function realmBadges(realm) {
  const r = await fetch(
    `https://grid-compute.com/api/registry/entity?realm=${encodeURIComponent(realm)}`
  );
  const j = await r.json();
  return j.badges; // { realm, key, verified }
}

const b = await realmBadges("fire");
// Render chips only — never show internal wire IDs in the address bar

Operator announce (server-side only)

bash
# Run on the node — secret from env, never from a browser
curl -sS -X POST https://grid-compute.com/api/registry/computes \
  -H 'content-type: application/json' \
  -H "authorization: Bearer $GRID_WEBHOOK_SECRET" \
  -d @announce.json

Prefer the GRID CLI ember loop over hand-rolled announce scripts in production — it handles heartbeats, sanitization, and backoff.