Point
Overview
Most but not all of our data is time-series. For example, sometimes bathymetry is static. Point requests return data for the selected variables and points. You can query these either by a basic GET request or by a POST request as shown below.
Example
Request
let url = '{{ &forecastUrl }}/point';
let data = {
points: [{lon: 174.7842, lat: -37.7935}],
variables: ['sea.depth.below-sea-level']
};
let options = {
method: 'post',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json',
'x-api-key': '{{apiKey}}'
}
};
await fetch(url, options)
.then(response => {
console.log('API response status:', response.status);
return response.json();
}).then(json => {
console.log('API response JSON:', json);
document.getElementById('response').innerHTML = JSON.stringify(json);
});
curl -X 'POST' \
'{{ &forecastUrl }}/point' \
-H 'x-api-key: {{apiKey}}' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"points": [{
"lon": 174.7842,
"lat": -37.7935
}],
"variables": [
"sea.depth.below-sea-level"
]
}'
# you may need to run "pip3 install requests" in your environment
from requests import post
resp = post('{{ &forecastUrl }}/point',
headers={'x-api-key': '{{apiKey}}'},
json={
"points": [{
"lon": 174.7842,
"lat": -37.7935
}],
"variables": [
"sea.depth.below-sea-level"
]
}
)
assert resp.status_code == 200
print(resp.json()['variables']['sea.depth.below-sea-level']['data'])
Response
{
"dimensions": {
"point": {
"type": "point",
"units": "unknown",
"data": [
{
"lon": 174.7842,
"lat": -37.7935
}
]
}
},
"noDataReasons": {
"ERROR_INTERNAL": 4,
"FILL": 1,
"GOOD": 0,
"INVALID_HIGH": 3,
"INVALID_LOW": 2
},
"variables": {
"sea.depth.below-sea-level": {
"standardName": "sea_floor_depth_below_mean_sea_level",
"units": "meter",
"dimensions": [
"point"
],
"data": [
22.357956
],
"noData": [
0
]
}
}
}