Skip to content

HAPI server conventions

Bob Weigel edited this page Dec 29, 2025 · 3 revisions

If you are developing a HAPI server, the following are conventions that are used for existing servers. Following these conventions will allow your server to re-use existing configurations and allow, in some cases, swapping one server implementation with another with minimal effort. Also, not having to document features that are part of the convention.

Discuss caching options. Other optimizations. Last modified.

If you are looking to not reinvent, could use.

Starting server

If server starts from command line implement the following options:

hapiserver -p PORT -c CONFIG

and ideally

hapiserver --port PORT --config CONFIG

(If not, for example for case where WAR file ..., ignore above.)

Config file (JSON)

{
"about": {
   HAPI: "3.2"
}

// Style is not decided upon yet.
// Note that HAPI and status are not needed and are ignored (HAPI from about above is used; if no match, warn.)

"catalog_file": String path to JSON file
or
"catalog_inline": JSON object

// Error if more than one catalog method given

e.g.,
"catalog_command": "node catalog.js" // could be any c/l program that returns JSON
"catalog_command": "python catalog.py"
"catalog_command": "cat /tmp/catalog.json"

Misconfig of server (catalog.json does not exist, exit(not zero)) => Server creates and sends 500 JSON
Misconfig of server (cat cmd does not exist, exit(not zero)) => Server creates and sends 500 JSON

// Always sends back all parameters, server subsets. 
"info_command": "python info.py --dataset {DATASET}" 
// Same error behavior as above
// startDate and stopDate may be

now now-DURATION

etc. See https://github.com/hapi-server/server-java/wiki (discouraged, unless computing takes a long time)

"data_command": "python data.py --dataset {DATASET}" // Server subsets parameters and on time
"data_command": "python data.py --dataset {DATASET} --parameters {PARAMETERS}" // Server subsets on time
"data_command": "python data.py --dataset {DATASET} --parameters {PARAMETERS} --start {START} --stop {STOP}" // Both start and stop required if one given
// Same error behavior as above if no data returned
// If error after data already sent; see https://github.com/hapi-server/data-specification/issues/211

data_uri_template = https://jfaden.net/~jbf/data/gardenhouse/data/PoolTemperature/$Y/28.FF6319A21705.$Y$m$d.csv
// If media-type cannot be determined from extension, use
data_uri_template = {
"media-type"
"template"
}
}

Clone this wiki locally