Route Time-Series
Overview
Sometimes it is convenient to request data for a route - a sequence of unique points where each point has a corresponding time. Route data is only available by POST request.
Example
Request
let url = '{{ &forecastUrl }}/route/speed';
let data = {
route: [
{
lon: 186.77271306302663,
lat: -30.939924331023455,
time: '{{fromDate}}T00:00:00Z'
},
{
lon: 181.8061859929176,
lat: -30.145127183376115,
time: '{{fromDate}}T03:00:00Z'
},
{
lon: 177.63078712866664,
lat: -29.878755346037977,
time: '{{fromDate}}T06:00:00Z'
}
],
variables: ['wave.height']
};
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 }}/route/time' \
-H 'x-api-key: {{apiKey}}' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"route": [{
"lon": 186.77271306302663,
"lat": -30.939924331023455,
"time": "{{fromDate}}T00:00:00Z"
},
{
"lon": 181.8061859929176,
"lat": -30.145127183376115,
"time": "{{fromDate}}T03:00:00Z"
},
{
"lon": 177.63078712866664,
"lat": -29.878755346037977,
"time": "{{fromDate}}T06:00:00Z"
}],
"variables": [
"wave.height"
]
}'
# you may need to run "pip3 install requests" in your environment
from requests import post
resp = post('{{ &forecastUrl }}/route/time',
headers={'x-api-key': '{{apiKey}}'},
json={
"route": [
{
"lon": 186.77271306302663,
"lat": -30.939924331023455,
"time": "{{fromDate}}T00:00:00Z"
},
{
"lon": 181.8061859929176,
"lat": -30.145127183376115,
"time": "{{fromDate}}T03:00:00Z"
},
{
"lon": 177.63078712866664,
"lat": -29.878755346037977,
"time": "{{fromDate}}T06:00:00Z"
}
],
"variables": [
"wave.height"
]
}
)
assert resp.status_code == 200
print(resp.json()['variables']['wave.height']['data'])
Response
{
"dimensions": {
"timepoint": {
"type": "timepoint",
"units": "unknown",
"data": [
{
"lon": 186.77271306302663,
"lat": -30.939924331023455,
"time": "{{fromDate}}T00:00:00Z"
},
{
"lon": 181.8061859929176,
"lat": -30.145127183376115,
"time": "{{fromDate}}T03:00:00Z"
},
{
"lon": 177.63078712866664,
"lat": -29.878755346037977,
"time": "{{fromDate}}T06:00:00Z"
}
]
}
},
"noDataReasons": {
"GOOD": 0,
"MASK_ICE": 1,
"ERROR_INTERNAL": 2,
"FILL": 3,
"INVALID_LOW": 4,
"INVALID_HIGH": 5,
"MASK_LAND": 6
},
"variables": {
"wave.height": {
"standardName": "sea_surface_wave_significant_height",
"units": "meter",
"dimensions": [
"timepoint"
],
"data": [
2.6266286,
2.0582612,
2.0589638
],
"noData": [
0,
0,
0
]
}
}
}