Use the Python client#

geonemo.client is the typed client of the REST API: one transport and credential set shared by an attribute per capability.

Prerequisites#

  • Python 3.11 or later.

  • A server URL. Where the server requires sign-in, see Sign in and tokens after installing.

Install#

From a checkout of the repository:

pip install ./contracts/client

The distribution contains no database drivers, server framework or MCP tools. Optional packs ship their own area clients, such as geonemo-maritime-client.

Connect#

from geonemo.client import GeoNeMoClient

with GeoNeMoClient(
    "https://geonemo.example.com",
    project_id="coastal-change",
) as client:
    document = client.discover()
    print(document.api_version, document.capabilities)

Argument

Meaning

base_url

Server origin; redirects are never followed

project_id

Sent as X-GeoNemo-Project-ID, default default

token

Bearer token; without it the client uses the saved geonemo login

timeout

Seconds or an httpx.Timeout, default 10

client, headers

Your own httpx.Client, extra single-line headers

Areas#

Attribute

Guide

client.catalog

Search the catalog

client.media

Preview imagery

client.gkb

Read and publish knowledge

client.layers

Use collection layers and the ontology

client.retrieval

Search with corpora

client.embeddings

Choose an embedding setup

client.events

Follow event feeds

client.status, client.gpus

Readiness, incidents and GPU status

Errors#

Every failure raises an error derived from the client’s base error (ServicesClientError), which carries status_code, retryable and operation. Messages never include URLs, headers or bodies.

Exception

Raised for

ServicesValidationError

HTTP 400 or 422

ServicesNotFoundError

HTTP 404

ServicesConflictError

HTTP 409, including a reused idempotency key

ServicesUnavailableError

HTTP 408, 425, 429 and 5xx; retryable is true

ServicesTimeoutError

The request timed out; a subclass of ServicesUnavailableError, so catching Unavailable also catches Timeout

ServicesProtocolError

A success response broke the contract

Test without a server#

FakeGeoNeMoClient mirrors .gkb, .catalog, .media and .status in memory.

from geonemo.client import CatalogRecord, FakeGeoNeMoClient

client = FakeGeoNeMoClient()
client.catalog.add_record(
    CatalogRecord(id="preview-coast-001", collection="preview-imagery")
)
print(client.catalog.get_record("preview-imagery", "preview-coast-001").id)

Result#

Calls return typed models. See Python client for every class and method.