Skip to content

REST API

eightysteele edited this page Mar 16, 2011 · 30 revisions

REST API

Cell lookup by value

Example request - "Get all bio1 variable cell values that are between 0 and 10 inclusive"

GET api/cells/values?within=5&pivot=5&variable=bio1&limit=10&offset=0

Parameter Description
within Look for values within this range
pivot Look for values within range of this pivot value
variable The cell variable
limit The max number of cells to return (for paging)
offset The starting point offset of cells to return (for paging)

Example JSON response

[
  {"cell-key": "1-2-3", "cell-value": 8},
  ...
]

Lookup cells by coordinates or cell keys

Example - "Get cell values for a list of variables that correspond to a list of coordinates (or cell keys)"

GET /api/cells/values?ll=1,2|7,3&v=bio1,bio2

Parameter Description
ll A latitude/longitude pair separated by a comma (",") or list of pairs separated by a pipe ("|")
k Cell keys separated by a comma (",")
v Variable names separated by a comma (",") or 'all' for all variables
nodata Set to 'true' and NODATA cells will be included in the response (default value is 'false')

Example JSON response

[
  {
    "coordinate": [1,2], 
    "cell-key": "1-2-3", 
    "cell-values": 
      [
        {"name": "bio1", "value": -50},
        {"name": "bio2", "value": -89}
      ]
  },
  {
    "coordinate": [7,3], 
    "cell-key": "2-8-3", 
    "cell-values": 
      [
        {"name": "bio1", "value": -22},
        {"name": "bio2", "value": 77}
      ]
  }
]

Get cell coordinates by cell key

Example - "Get the cell coordinates for cells 1-2-3 and 2-8-3"

GET /api/cells/coordinates?k=1-2-3,2-8-3

Parameter Description
k Cell keys separated by a comma (",")

Example JSON response

[
  {
    "cell-key": "1-2-3",
    "coordinates": 
      [
        [-122.2887875,37.8603069],
        [-122.2774275,37.8603069],
        [-122.2729888,37.8686002],
        [-122.2843488,37.8686002],
        [-122.2887875,37.8603069]
      ],
  },
  {
    "cell-key": "2-8-3",
    "coordinates": 
      [
        [-122.2887875,37.8603069],
        [-122.2774275,37.8603069],
        [-122.2729888,37.8686002],
        [-122.2843488,37.8686002],
        [-122.2887875,37.8603069]
      ]
  }
]

List all variables

Example - "List all variables."

GET /api/variables

Example JSON response

[
  {
    "bio1": {
      "maxval": 293,
      "name": "Annual Mean Temperature",
      "created": "2006-01-04 00:00:00",
      "minval": -50,
      "datum": "WGS84",
      "database": "WorldClim",
      "version": "1.4",
      "key": "bio1",
      "release": 3,
      "projection": "Geographic"
    },
    ...
  }
]

List variable by name

Example - "List metadata for variable bio1"

GET /api/variables/bio1

Example JSON response

{
  "maxval": 293,
  "name": "Annual Mean Temperature",
  "created": "2006-01-04 00:00:00",
  "minval": -50,
  "datum": "WGS84",
  "database": "WorldClim",
  "version": "1.4",
  "key": "bio1",
  "release": 3,
  "projection": "Geographic"
}

Clone this wiki locally