IRI API
Use scripted workflows. Prefer the bundled scripts over hand-written curl commands.
Deployments
| Site | Base URL | Auth script | Reference |
|---|---|---|---|
| NERSC (Perlmutter) | https://api.iri.nersc.gov (default) | scripts/token_manager.py ensure --facilities nersc | references/NERSC.md |
| ALCF (Polaris) | https://api.alcf.anl.gov | scripts/token_manager.py ensure --facilities alcf | references/ALCF.md |
Before doing any work, read the reference file for the relevant site. Do not proceed from memory.
Use the unified token manager for both sites. By default it can manage both NERSC and ALCF tokens together, but when the user is focused on one site, scope it with --facilities nersc or --facilities alcf.
--facility is a global flag on iri_api_call.py and must come before the subcommand:
bash# Correct python3 scripts/iri_api_call.py --facility nersc call --operation-id getProjects --ensure-token python3 scripts/iri_api_call.py --facility alcf call --operation-id launchJob ... # Wrong python3 scripts/iri_api_call.py call --facility nersc --operation-id getProjects
--base-url and --openapi-url follow the same rule: they are global flags and must also come before the subcommand.
Quick Start
- Check token state:
bashpython3 scripts/token_manager.py status --json
- Ensure a usable token for authenticated endpoints:
bashpython3 scripts/token_manager.py ensure --min-ttl 300
If the IRI API still returns 401, force a fresh identity-provider login:
bashpython3 scripts/token_manager.py ensure --force-login --prompt-login --validate-iri
- List available operations from OpenAPI:
bashpython3 scripts/iri_api_call.py --facility nersc list-operations python3 scripts/iri_api_call.py --facility alcf list-operations
- Call an endpoint by
operationId:
bashpython3 scripts/iri_api_call.py --facility nersc call --operation-id getResources python3 scripts/iri_api_call.py --facility alcf call --operation-id getResources
Token Management
Use scripts/token_manager.py for all token lifecycle actions.
- Check token state:
bashpython3 scripts/token_manager.py status --json python3 scripts/token_manager.py status --facilities nersc --json python3 scripts/token_manager.py status --facilities alcf --json
- Ensure usable tokens:
bashpython3 scripts/token_manager.py ensure --min-ttl 300 python3 scripts/token_manager.py ensure --facilities nersc --min-ttl 300 python3 scripts/token_manager.py ensure --facilities alcf --min-ttl 300
- Refresh or login for selected facilities only:
bashpython3 scripts/token_manager.py ensure --facilities nersc --refresh-only python3 scripts/token_manager.py ensure --facilities alcf --refresh-only
- Validate the facility token against the matching API:
bashpython3 scripts/token_manager.py ensure --facilities nersc --validate-iri --validate-facility nersc python3 scripts/token_manager.py ensure --facilities alcf --validate-iri --validate-facility alcf
- Print selected facility access tokens:
bashpython3 scripts/token_manager.py ensure --print-token python3 scripts/token_manager.py ensure --facilities alcf --print-token
Notes:
- Default token file:
~/.globus/auth_tokens.json - The saved file preserves the full Globus token response, including
other_tokens. - The usable IRI API bearer token is extracted from
other_tokens, not the top-level Globus Auth token. - Required scopes are enforced by script validation.
globus-sdkis required for refresh/login operations.- If validation reports empty
session_info.authentications, re-run with--force-login --prompt-loginand complete the flow in a Chrome incognito window.
Endpoint Execution
Use scripts/iri_api_call.py for all API calls.
Operation Discovery
- List all operations:
bashpython3 scripts/iri_api_call.py --facility nersc list-operations python3 scripts/iri_api_call.py --facility alcf list-operations
- See generated static reference:
references/operations.md
Public Endpoints (No Token Required)
Examples:
bashpython3 scripts/iri_api_call.py --facility nersc call --operation-id getFacility python3 scripts/iri_api_call.py --facility nersc call --operation-id getIncidents python3 scripts/iri_api_call.py --facility nersc call --operation-id getResource --path-param resource_id=perlmutter
Authenticated Endpoints (Token Required)
Use --ensure-token so calls auto-refresh/login if needed.
- Account / project context:
bashpython3 scripts/iri_api_call.py --facility nersc call --operation-id getProjects --ensure-token python3 scripts/iri_api_call.py --facility alcf call --operation-id getProjects --ensure-token
- Submit compute job (request body from file):
bashpython3 scripts/iri_api_call.py --facility nersc call \ --operation-id launchJob \ --path-param resource_id=perlmutter \ --json-file /path/to/job.json \ --ensure-token
- Query one job:
bashpython3 scripts/iri_api_call.py --facility nersc call \ --operation-id getJob \ --path-param resource_id=perlmutter \ --path-param job_id=12345 \ --ensure-token
- Cancel job:
bashpython3 scripts/iri_api_call.py --facility nersc call \ --operation-id cancelJob \ --path-param resource_id=perlmutter \ --path-param job_id=12345 \ --ensure-token
- Filesystem list/view:
bashpython3 scripts/iri_api_call.py --facility nersc call \ --operation-id ls \ --path-param resource_id=perlmutter \ --query path=/global/cfs/cdirs \ --ensure-token python3 scripts/iri_api_call.py --facility nersc call \ --operation-id view \ --path-param resource_id=perlmutter \ --query path=/path/to/file.txt \ --ensure-token
- Upload file:
bashpython3 scripts/iri_api_call.py --facility nersc call \ --operation-id upload \ --path-param resource_id=perlmutter \ --query path=/path/on/resource/target.dat \ --upload-file /local/path/source.dat \ --ensure-token
- Poll task state:
bashpython3 scripts/iri_api_call.py --facility nersc call --operation-id getTasks --ensure-token python3 scripts/iri_api_call.py --facility nersc call --operation-id getTask --path-param task_id=<task_id> --ensure-token
Shared Parameter Rules
- Prefer
--operation-idover manual--method/--path. - Provide required path params via repeated
--path-param key=value. - Provide query params via repeated
--query key=value. - Use one of:
--json-file /path/to/body.json--json-body '{"key":"value"}'--upload-file /path/to/local.filefor multipart endpoints
- For binary or large outputs, use
--output-file /path/to/out.bin. - Use
--facility nerscor--facility alcfonscripts/iri_api_call.pyso the API server and bearer token selection stay aligned.
Job Construction Guidance
Before generating a compute job request, check whether the user wants any of the following:
- A multistep job with multiple
srunormpiexeclines. - Additional job-control behavior that is not covered by the API
attributesfields. - Explicit affinity or binding control beyond the basic resource request.
If any of those are needed, use a pre_launch or post_launch script to carry that logic instead of trying to force it into a single launch line or into unsupported attributes.
Rules for these scripts:
- Do not include
#SBATCHor#PBSdirectives inpre_launchorpost_launch. - The scheduler directives belong in the batch script generated by the API server, not inside the pre/post scripts.
- Put extra
srunormpiexeclines, affinity settings, environment setup, and teardown logic in those scripts as plain shell commands. - For NERSC-oriented launch structure and Slurm examples, use
https://docs.nersc.gov/jobs/examples/. - For ALCF-oriented launch structure and PBS examples, use
https://docs.alcf.anl.gov/running-jobs/example-job-scripts/#cpu-mpi-openmp-examples.
Reproducibility and Reference Refresh
Regenerate endpoint reference after OpenAPI updates:
bashpython3 scripts/generate_operation_reference.py \ --openapi references/openapi.json \ --output references/operations.md
Regenerate request payload templates:
bashpython3 scripts/generate_examples.py
Use templates from references/examples/:
compute-launch-job.jsoncompute-status-filters.jsonfilesystem-mkdir.jsonfilesystem-mv.jsonfilesystem-cp.jsonfilesystem-compress.jsonfilesystem-extract.jsonfilesystem-chmod.jsonfilesystem-chown.json
Example calls using generated templates:
bashpython3 scripts/iri_api_call.py --facility nersc call \ --operation-id launchJob \ --path-param resource_id=perlmutter \ --json-file references/examples/compute-launch-job.json \ --ensure-token python3 scripts/iri_api_call.py --facility nersc call \ --operation-id mkdir \ --path-param resource_id=perlmutter \ --json-file references/examples/filesystem-mkdir.json \ --ensure-token
Useful Endpoint Groups
- Facility + status (public): infrastructure metadata and incident visibility.
- Account (auth): user projects and allocation hierarchy.
- Compute (auth): submit/update/status/cancel jobs.
- Filesystem (auth): list/read/write/upload/download and file operations.
- Task (auth): check asynchronous task progress and cleanup.


