Intro

SPOT provides a REST API that can be used in variety of languages (javascript, BASH, python, JAVA etc). The output is typically JSON formatted data.

Basic Usage in BASH


Login

POST

URL:
https://portal-auth.nersc.gov/als/auth

EXAMPLE:

% curl -k -c cookies.txt -X POST -d "username=[your_username]&password=[your_password]" https://portal-auth.nersc.gov/als/auth

Search Datasets

GET

URL:
https://portal-auth.nersc.gov/als/hdf/search

Arguments:
limitnum: number of results to show
skipnum: number of results to skip
sortterm: database field on which to sort (commonly fs.stage_date or appmetadata.sdate)
sorttype: desc or asc
search: query

Result:
JSON List

EXAMPLE:

% curl -k -b cookies.txt -X GET "https://portal-auth.nersc.gov/als/hdf/search?skipnum=0&limitnum=10&sortterm=fs.stage_date&sorttype=desc&search=end_station=bl832"

Find Derived Datasets (norm, sino, gridrec, imgrec) from raw dataset

GET

URL:
https://portal-auth.nersc.gov/als/hdf/dataset

Arguments:
dataset: raw dataset

Result:
JSON List

EXAMPLE:

% curl -k -b cookies.txt -X GET "https://portal-auth.nersc.gov/als/hdf/dataset?dataset=20130713_185717_Chilarchaea_quellon_F_9053427_IKI_"

View Attributes for Single Dataset and Image Within Dataset

GET

URL:
https://portal-auth.nersc.gov/als/hdf/attributes/[dataset]

Arguments:
group: path in hdf5 file. Set to "/" for overall attributes

Result:
JSON Array

EXAMPLE:

% curl -k -b cookies.txt -X GET "https://portal-auth.nersc.gov/als/hdf/attributes/als/bl832/hmwood/20130713_185717_Chilarchaea_quellon_F_9053427_IKI_/raw/20130713_185717_Chilarchaea_quellon_F_9053427_IKI_.h5?group=/"

List Images Within Dataset

GET

URL:
https://portal-auth.nersc.gov/als/hdf/listimages/[dataset]

Arguments:
None

Result:
JSON List (paths to images within the HDF5 file)

EXAMPLE:

% curl -k -b cookies.txt -X GET "https://portal-auth.nersc.gov/als/hdf/listimages/als/bl832/hmwood/20130713_185717_Chilarchaea_quellon_F_9053427_IKI_/raw/20130713_185717_Chilarchaea_quellon_F_9053427_IKI_.h5"

Stage Dataset From Tape to Disk if Required

GET

URL:
https://portal-auth.nersc.gov/als/hdf/stageifneeded/[dataset]

Arguments:
None

Result:
JSON Array

EXAMPLE:

% curl -k -b cookies.txt -X GET "https://portal-auth.nersc.gov/als/hdf/stageifneeded/als/bl832/hmwood/20130713_185717_Chilarchaea_quellon_F_9053427_IKI_/raw/20130713_185717_Chilarchaea_quellon_F_9053427_IKI_.h5"

Download Dataset

GET

URL:
https://portal-auth.nersc.gov/als/hdf/download/[dataset]

Arguments:
None

Result:
H5 File

EXAMPLE:

% curl -k -b cookies.txt -X GET "https://portal-auth.nersc.gov/als/hdf/download/als/bl832/hmwood/20130713_185717_Chilarchaea_quellon_F_9053427_IKI_/raw/20130713_185717_Chilarchaea_quellon_F_9053427_IKI_.h" > file.h5

Download Rawdata For Individual Image

GET

URL:
https://portal-auth.nersc.gov/als/hdf/rawdata/[dataset]

Arguments:
group: path in HDF5 file to image

Result:
JSON Array

EXAMPLE:

% curl -k -b cookies.txt -X GET "https://portal-auth.nersc.gov/als/hdf/rawdata/als/bl832/hmwood/20130713_185717_Chilarchaea_quellon_F_9053427_IKI_/norm/20130713_185717_Chilarchaea_quellon_F_9053427_IKI_-norm-20130714_192637.h5?group=/20130713_185717_Chilarchaea_quellon_F_9053427_IKI_/20130713_185717_Chilarchaea_quellon_F_9053427_IKI__0000_0640.tif"

Get Download URLs for .tif and .png files for individual image

GET

URL:
https://portal-auth.nersc.gov/als/hdf/image/[dataset]

Arguments:
group: path in HDF5 file to image

Result:
JSON Array

EXAMPLE:

% curl -k -b cookies.txt -X GET "https://portal-auth.nersc.gov/als/hdf/image/als/bl832/hmwood/20130713_185717_Chilarchaea_quellon_F_9053427_IKI_/norm/20130713_185717_Chilarchaea_quellon_F_9053427_IKI_-norm-20130714_192637.h5?group=/20130713_185717_Chilarchaea_quellon_F_9053427_IKI_/20130713_185717_Chilarchaea_quellon_F_9053427_IKI__0000_0640.tif"

Run TomoPy on an existing dataset

GET

URL:
https://portal-auth.nersc.gov/als/hdf/tomopyjob

Arguments:
dataset: raw dataset

Result:
JSON List

EXAMPLE:

% curl -k -b cookies.txt -X GET "https://portal-auth.nersc.gov/als/hdf/tomopyjob?dataset=20130713_185717_Chilarchaea_quellon_F_9053427_IKI_"


Basic Usage in Python


You can use the python requests module to interact with the API:

from requests import Session


Check Auth:

r = s.get("https://newt.nersc.gov/newt/auth")

r = s.post("https://newt.nersc.gov/newt/auth", {"username": "shreyas", "password": "XXXX"})


To see the result do

r.status

r.content


See the BASH section above for more commands.