Route Speed
Overview
Given a start time, a series of points, and a series of speeds in meters per second between those points, the route speed endpoint will determine the corresponding time for every point after the first. Route data is only available by POST request.
Example
Request
let url = '{{ &forecastUrl }}/route/speed';
let data = {
start: '{{fromDate}}T00:00:00Z',
speeds: [10.2, 14.5],
points: [
{lon: 186.77271306302663, lat: -30.939924331023455},
{lon: 181.8061859929176, lat: -30.145127183376115},
{lon: 177.63078712866664, lat: -29.878755346037977}
],
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/speed' \
-H 'x-api-key: {{apiKey}}' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"start": "{{fromDate}}T00:00:00Z",
"points": [{
"lon": 186.77271306302663,
"lat": -30.939924331023455
},
{
"lon": 181.8061859929176,
"lat": -30.145127183376115
},
{
"lon": 177.63078712866664,
"lat": -29.878755346037977
}],
"speeds": [10.2, 14.5],
"variables": [
"wave.height"
]
}'
# you may need to run "pip3 install requests" in your environment
from requests import post
resp = post('https://forecast-v2.metoceanapi.com/route/speed',
headers={'x-api-key': 'gregcisace'},
json={
"start": "{{fromDate}}T00:00:00Z",
"points": [
{
"lon": 186.77271306302663,
"lat": -30.939924331023455
},
{
"lon": 181.8061859929176,
"lat": -30.145127183376115
},
{
"lon": 177.63078712866664,
"lat": -29.878755346037977
}
],
"speeds": [10.2, 14.5],
"variables": [
"wave.height"
]
}
)
print(resp, resp.json())
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}}T13:11:50Z"
},
{
"lon": 177.63078712866664,
"lat": -29.878755346037977,
"time": "{{fromDate}}T20:56:03Z"
}
]
}
},
"noDataReasons": {
"ERROR_INTERNAL": 3,
"FILL": 4,
"GOOD": 0,
"INVALID_HIGH": 6,
"INVALID_LOW": 5,
"MASK_ICE": 2,
"MASK_LAND": 1
},
"variables": {
"wave.height": {
"standardName": "sea_surface_wave_significant_height",
"units": "meter",
"dimensions": [
"timepoint"
],
"data": [
2.6266286,
2.026932,
2.2947452
],
"noData": [
0,
0,
0
]
}
}
}