iri-client
Rust client + Python bindings for the NERSC IRI API, driven by the OpenAPI 3.1
spec in openapi/openapi.json.
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=... 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 (Async)
A small async CLI binary is included at src/bin/iri-cli.rs.
# 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
Python Bindings
Install from PyPI:
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 OAuth2>"
# 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.py
OAuth2 token helper script (authlib + PrivateKeyJWT):
examples/generate_auth_token.py