iri-client
Rust client + Python bindings for the NERSC IRI API OpenAPI 3.1
spec in openapi/openapi.json.
Python Bindings
Install from PyPI:
or build the extension module locally:
# Use maturin >= 1.9.4
Python operation examples
=
# List operation ids
=
# Public operation
# Path params
# Auth-required operation
# access_token = "<token from GlobusAuth>"
# auth_client = Client(base_url="https://api.iri.nersc.gov", access_token=access_token)
# print(auth_client.call_operation("getProjects"))
Full runnable Python operation script:
examples/python_module_example.pyexamples/python_async_module_example.py(async withAsyncClient)examples/submit_job.py(submit a job to IRI api and monitor status)
Authentication Model
This API uses header Authorization with the raw access token value:
Authorization: <access_token>
This client follows that behavior when you call with_authorization_token(...)
or pass access_token=... to the client's constructor in Python.
Runnable Cargo Examples
These are checked-in Rust examples you can run directly:
# Lists generated operation ids/methods/paths (no network calls)
# Calls getResources with query parameters
# Same example with custom base URL and limit
IRI_BASE_URL=https://api.iri.nersc.gov IRI_RESOURCE_LIMIT=10 \
# Calls auth-required getProjects
IRI_ACCESS_TOKEN=<access-token> cargo
# Async IriClient examples
IRI_ACCESS_TOKEN=<access-token> cargo
# Async ApiClient example (raw path + query)
CLI Tool
A small CLI binary iri-cli is included. One can install it through cargo. It is
currently not distributed in the python package.
Here are a few examples on how to use the cli client.
# Show generated operations
# Filter operation ids
# Call by OpenAPI operation id with query params
# Call operation with path params
# Raw method/path request
# Authenticated operation
IRI_ACCESS_TOKEN=<access-token> \
Rust Examples (OpenAPI Operation Client)
Use IriClient when calling by OpenAPI operationId.
Public endpoint: getFacility
use IriClient;
async
Query parameters: getResources
use IriClient;
async
Path parameter: getSite
use IriClient;
async
Auth-required endpoint: getProjects
use IriClient;
async
Rust Examples (Generic REST Client)
Use ApiClient when you want direct method/path control.
use ApiClient;
async