Rust client and Python bindings for the NERSC IRI API
Project description
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)
cargo run --example blocking_list_operations
# Calls getResources with query parameters
cargo run --example blocking_get_resources
# Same example with custom base URL and limit
IRI_BASE_URL=https://api.iri.nersc.gov IRI_RESOURCE_LIMIT=10 \
cargo run --example blocking_get_resources
# Calls auth-required getProjects
IRI_ACCESS_TOKEN=<access-token> cargo run --example blocking_get_projects
# Async IriClient examples
cargo run --example async_get_resources
IRI_ACCESS_TOKEN=<access-token> cargo run --example async_get_projects
# Async ApiClient example (raw path + query)
cargo run --example async_api_client_sites
CLI Tool (Async)
A small async CLI binary is included at src/bin/iri-cli.rs.
# Show generated operations
cargo run --features cli --bin iri-cli -- operations
# Filter operation ids
cargo run --features cli --bin iri-cli -- operations --filter Job
# Call by OpenAPI operation id with query params
cargo run --features cli --bin iri-cli -- call getResources --query limit=5 --query offset=0
# Call operation with path params
cargo run --features cli --bin iri-cli -- call getSite --path-param site_id=<site-id>
# Raw method/path request
cargo run --features cli --bin iri-cli -- request GET /api/v1/facility/sites --query limit=5
# Authenticated operation
IRI_ACCESS_TOKEN=<access-token> \
cargo run --features cli --bin iri-cli -- call getProjects
Rust Examples (OpenAPI Operation Client)
Use IriClient when calling by OpenAPI operationId.
Public endpoint: getFacility
use iri_client::IriClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = IriClient::from_openapi_default_server()?;
let facility = client
.call_operation("getFacility", &[], &[], None)
.await?;
println!("{facility}");
Ok(())
}
Query parameters: getResources
use iri_client::IriClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = IriClient::new("https://api.iri.nersc.gov")?;
let resources = client
.call_operation(
"getResources",
&[],
&[("limit", "10"), ("offset", "0"), ("resource_type", "compute")],
None,
)
.await?;
println!("{resources}");
Ok(())
}
Path parameter: getSite
use iri_client::IriClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = IriClient::new("https://api.iri.nersc.gov")?;
let site = client
.call_operation("getSite", &[("site_id", "dd7f822a-3ad2-54ae-bddb-796ee07bd206")], &[], None)
.await?;
println!("{site}");
Ok(())
}
Auth-required endpoint: getProjects
use iri_client::IriClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let access_token = std::env::var("IRI_ACCESS_TOKEN")?;
let client = IriClient::new("https://api.iri.nersc.gov")?
.with_authorization_token(access_token);
let projects = client
.call_operation("getProjects", &[], &[], None)
.await?;
println!("{projects}");
Ok(())
}
Rust Examples (Generic REST Client)
Use ApiClient when you want direct method/path control.
use iri_client::ApiClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = ApiClient::new("https://api.iri.nersc.gov")?;
let sites = client
.get_json_with_query("/api/v1/facility/sites", &[("limit", "5"), ("offset", "0")])
.await?;
println!("{sites}");
Ok(())
}
Python Bindings
Install from PyPI:
pip install iri-client
Build the extension module locally:
# Use maturin >= 1.9.4
maturin develop --features python
Python operation examples
import json
from iri_client import Client
client = Client(base_url="https://api.iri.nersc.gov")
# List operation ids
operation_ids = Client.operation_ids()
print(f"Loaded {len(operation_ids)} operations from generated catalog")
print("First 10 operation ids:")
for operation_id in operation_ids[:10]:
print(f" - {operation_id}")
# Public operation
print(client.call_operation("getFacility"))
# Path params
print(
client.call_operation(
"getSite",
path_params_json=json.dumps({"site_id": "dd7f822a-3ad2-54ae-bddb-796ee07bd206"}),
)
)
# 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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file iri_client-0.1.0.tar.gz.
File metadata
- Download URL: iri_client-0.1.0.tar.gz
- Upload date:
- Size: 43.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32f2bcb39781b2ed7a9de4a2a048023f8d61520ac0f49ef97561d66aefe3ed93
|
|
| MD5 |
df1370e1a8a38fa578ebb25842ac1778
|
|
| BLAKE2b-256 |
a321848561ffeb522b720bded9f5db21eb0721b27b9d037dc886d43519c98fe0
|
File details
Details for the file iri_client-0.1.0-cp39-abi3-win_arm64.whl.
File metadata
- Download URL: iri_client-0.1.0-cp39-abi3-win_arm64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.9+, Windows ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01178e0386720acf88f47421bcddea067e78ceb8d7ba26600f9d86577c2eecc4
|
|
| MD5 |
e070feadfe4909e3f696683ba0ec9738
|
|
| BLAKE2b-256 |
35d9dc71c9401717fdad3f0a7d06ac65ce5b5e86fe547d6877b7b2e46e483ce9
|
File details
Details for the file iri_client-0.1.0-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: iri_client-0.1.0-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b67d90140159b56f8f5655e35e666e792ab30064ca274b67fb54aebe4b14d62
|
|
| MD5 |
301ecc49f7e06aa9992e4efd162cbe5b
|
|
| BLAKE2b-256 |
b1f92d8949ad8230ec929b3e303e4fa9a0f5f714e2e0fd1fc41a57218ce65221
|
File details
Details for the file iri_client-0.1.0-cp39-abi3-win32.whl.
File metadata
- Download URL: iri_client-0.1.0-cp39-abi3-win32.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.9+, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f6356c3da14ed79ee9c029e3d89f0f55d48bbc6c4a2da783b370273d3c260f1
|
|
| MD5 |
ab4cf2fa3da4881c455dd73396de75d0
|
|
| BLAKE2b-256 |
470de6df0741eebc83a010d627b4995ae8b950458f6cff0a4c06700204d0f806
|
File details
Details for the file iri_client-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: iri_client-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 3.0 MB
- Tags: CPython 3.9+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c09d779714b733f7ac5156e57c653f57ce3edf29820a3c39e307b56e84a1c9e6
|
|
| MD5 |
dc4a948e1c513235eb3e805297cbfc6b
|
|
| BLAKE2b-256 |
0f2e9b949e3e12bb5befe0a3c3a4161d9b13a0295a2809e2121becac39c13830
|
File details
Details for the file iri_client-0.1.0-cp39-abi3-musllinux_1_2_i686.whl.
File metadata
- Download URL: iri_client-0.1.0-cp39-abi3-musllinux_1_2_i686.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.9+, musllinux: musl 1.2+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c35a9bf80afa3259e15f57e6029a9a7b17ebbfa32521ceaa6370830c20d1008
|
|
| MD5 |
e970d63c52c9307e9567c9d204ce1b8a
|
|
| BLAKE2b-256 |
ed43f851179196472606e329458f6333c3b6100eda443458e3b2f44ffc4ddb6a
|
File details
Details for the file iri_client-0.1.0-cp39-abi3-musllinux_1_2_armv7l.whl.
File metadata
- Download URL: iri_client-0.1.0-cp39-abi3-musllinux_1_2_armv7l.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.9+, musllinux: musl 1.2+ ARMv7l
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4430be9cd5d5aa0c1a0a389c40a34465f604935df868d313517aefb5d4ca162
|
|
| MD5 |
00219f89f286be4c7f6ddc8efab38c83
|
|
| BLAKE2b-256 |
cfc9211a50601042ba55e767e8dffdb032fbfa44859384a58340f8bf979c77a4
|
File details
Details for the file iri_client-0.1.0-cp39-abi3-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: iri_client-0.1.0-cp39-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 2.8 MB
- Tags: CPython 3.9+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
547fb6aa123be07adf50ec4da74e9a668ef83ddbbe5201555d5df5191bb2ccd5
|
|
| MD5 |
f79a35558d7893b9cef7c9c242bd8413
|
|
| BLAKE2b-256 |
c4da028178cf434661b8817573ef4d47e7d1a3c832023ff8c302cb1a009d72f6
|
File details
Details for the file iri_client-0.1.0-cp39-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: iri_client-0.1.0-cp39-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.8 MB
- Tags: CPython 3.9+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4178282401691172990bdd0264c04d496290a7c378837d9ed3d722b5905e7e6f
|
|
| MD5 |
9d1a115e646cfb04178c9c74ec83838f
|
|
| BLAKE2b-256 |
3bc629e665e01fe75a4fad7a6e60d63d82b4e199fc03f23692808cbdf5cfc05f
|
File details
Details for the file iri_client-0.1.0-cp39-abi3-manylinux_2_28_s390x.whl.
File metadata
- Download URL: iri_client-0.1.0-cp39-abi3-manylinux_2_28_s390x.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.9+, manylinux: glibc 2.28+ s390x
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19db73c0ff2acd460e809de3493c569fb613260f6c462c354880aa7abad81847
|
|
| MD5 |
f830a394c5fcb50de44621a0ac4e80d7
|
|
| BLAKE2b-256 |
6b5590294c966dfbf4b47813c8c2806d0dc5d7944be234d909412a1d2dd5c515
|
File details
Details for the file iri_client-0.1.0-cp39-abi3-manylinux_2_28_ppc64le.whl.
File metadata
- Download URL: iri_client-0.1.0-cp39-abi3-manylinux_2_28_ppc64le.whl
- Upload date:
- Size: 2.9 MB
- Tags: CPython 3.9+, manylinux: glibc 2.28+ ppc64le
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06f5d8fd04d6175b8aba612723d910a0f6188ec0c0d43eff442825df1e79d96f
|
|
| MD5 |
137d18b66fbf0fb87e9c7eee08025148
|
|
| BLAKE2b-256 |
4ee196f219303eb080cd7514e7336e96596e245eb5bbcaefab8da81dfd7dedff
|
File details
Details for the file iri_client-0.1.0-cp39-abi3-manylinux_2_28_i686.whl.
File metadata
- Download URL: iri_client-0.1.0-cp39-abi3-manylinux_2_28_i686.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.9+, manylinux: glibc 2.28+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4fd4b34d6b444410684523c8feada449634295fbd26ed4ae6f86259726085b3
|
|
| MD5 |
b9b7b20e6b668385355ba53c546b944c
|
|
| BLAKE2b-256 |
70e1b897f987c2fe026046b775a7b2da46b86abc0622a47a217c8b3f30b5d222
|
File details
Details for the file iri_client-0.1.0-cp39-abi3-manylinux_2_28_armv7l.whl.
File metadata
- Download URL: iri_client-0.1.0-cp39-abi3-manylinux_2_28_armv7l.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.9+, manylinux: glibc 2.28+ ARMv7l
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd444d4caec10c3e8c9f3b50aea457cb0de9ab094c3f2c2fa22878cdc1fa38f1
|
|
| MD5 |
023400376a8b11cdffe800d4a75e1ffb
|
|
| BLAKE2b-256 |
633b5f88f5885c4d7b42275ab38b0c24e1def6739d49f7ed1c31337e5b789087
|
File details
Details for the file iri_client-0.1.0-cp39-abi3-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: iri_client-0.1.0-cp39-abi3-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.9+, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7125e3b22677daf8f493e0fef6755c0eb17312d005ad97bcf78b3430227d730
|
|
| MD5 |
dff91c9022687d426792de883f40165d
|
|
| BLAKE2b-256 |
a543d1b2881a95f944397f92d71a08a1e82ef327346d7f678ecd0f26b0a98063
|
File details
Details for the file iri_client-0.1.0-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: iri_client-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64629f88ab71966400fd6f876667201441c85774cc10843fa75e426736d1556a
|
|
| MD5 |
c833a4160e2f5aa3e4cf2b0283abff51
|
|
| BLAKE2b-256 |
fc1350563c76adb9e9ccfac76e2ea4d2aea20643eee28e7635c9004d6662f4e0
|
File details
Details for the file iri_client-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: iri_client-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a2a5f29a0100ff07db196e8ecc50b4d0b3fa374154e66ca594f0ec456c77404
|
|
| MD5 |
7cd81bd182c5526ed38ef256e7c1621b
|
|
| BLAKE2b-256 |
9b6928cd5afea1e2c64e3f399b0d7af58d7158c2282a47bbfac301eb577b3794
|