MARS documentation
Protocol

Query your first registry

A complete read-only discovery and resolution workflow.

You need Python 3 and a registry base URL supplied by its operator. These examples do not assume a public hosted endpoint.

Discover and resolve

Set MARS_REGISTRY_URL to your registry's HTTPS origin. The program checks health, discovers at most five complete records, and resolves the first result when one exists. An empty registry is a valid result.

discover.py
import json
import os
from urllib.parse import quote
from urllib.request import Request, urlopen

base = os.environ["MARS_REGISTRY_URL"].rstrip("/")

def request(path, payload=None):
    data = None if payload is None else json.dumps(payload).encode()
    headers = {"Accept": "application/json"}
    if data is not None:
        headers["Content-Type"] = "application/json"
    with urlopen(Request(base + path, data=data, headers=headers), timeout=15) as response:
        return json.load(response)

print("health:", request("/v1/health"))
result = request("/v1/discover/marsql", {"query": "DISCOVER * LIMIT 5"})
print(json.dumps(result, indent=2))
entries = result.get("entries", [])
if entries:
    did = quote(entries[0]["entryDid"], safe="")
    print("resolved:", request("/v1/entries/" + did))
else:
    print("No matching entries in this registry.")
python3 discover.py

What to inspect

Check each record's entryType, publisherDid, itemSchemaUri, itemDataHash, and signature. Discovery returns complete records; verification is a separate client responsibility. Read signatures before trusting a record.

Handle failures

A transport or health failure is different from zero matches. The example propagates HTTP errors instead of converting failures to empty results. For pagination, reuse the returned opaque cursor with the same query and ordering; see MARS-QL.

Source authority

This page describes the checked-in implementation, not the availability of a public registry.

  • mars-server/src/api/mod.rs
  • mars-server/src/contracts.rs
  • docs/api/openapi.v1.json
  • mars-protocol/src/marsql/ast.rs

On this page