Sofar API
Search…
⌃K

Forecast Data

Working examples of interacting with the Forecast Data marine weather endpoint.
Responses in these examples have been abridged to only show a few values from the larger 10-day forecast.

Retrieve forecast data for a single variable

Example request

curl "https://api.sofarocean.com/marine-weather/v1/models/"\
"Wave/forecast/point"\
"?longitude=-152.0001&latitude=37.0001"\
"&variableIDs=significantWaveHeight"\
"&token=YOUR_API_TOKEN_HERE"
1
{
2
"modelID": "Wave",
3
"requestTime": "2022-09-20T19:26:45.812Z",
4
"requestLocation": {
5
"latitude": 37.0001,
6
"longitude": -152.0001
7
},
8
"forecastVariables": [
9
{
10
"variableID": "Wave-significantWaveHeight",
11
"variableName": "significantWaveHeight",
12
"physicalUnit": "m",
13
"values": [
14
{
15
"timestamp": "2022-09-20T12:00:00.000Z",
16
"value": 1.6149866487045847,
17
"leadTimeHours": 6
18
},
19
{
20
"timestamp": "2022-09-20T13:00:00.000Z",
21
"value": 1.6202169881441968,
22
"leadTimeHours": 7
23
},
24
{
25
"timestamp": "2022-09-20T14:00:00.000Z",
26
"value": 1.6205206852729486,
27
"leadTimeHours": 8
28
}
29
]
30
}

Retrieve forecast data for multiple variables

Example request

curl "https://api.sofarocean.com/marine-weather/v1/models/"\
"Wave/forecast/point"\
"?longitude=-152.0001&latitude=37.0001"\
"&variableIDs=significantWaveHeight,meanDirection"\
"&token=YOUR_API_TOKEN_HERE"
{
"modelID": "Wave",
"requestTime": "2022-09-20T19:28:01.701Z",
"requestLocation": {
"latitude": 37.0001,
"longitude": -152.0001
},
"forecastVariables": [
{
"variableID": "Wave-significantWaveHeight",
"variableName": "significantWaveHeight",
"physicalUnit": "m",
"values": [
{
"timestamp": "2022-09-20T12:00:00.000Z",
"value": 1.6149866487045847,
"leadTimeHours": 6
},
{
"timestamp": "2022-09-20T13:00:00.000Z",
"value": 1.6202169881441968,
"leadTimeHours": 7
},
{
"timestamp": "2022-09-20T14:00:00.000Z",
"value": 1.6205206852729486,
"leadTimeHours": 8
}
]
},
{
"variableID": "Wave-meanDirection",
"variableName": "meanDirection",
"physicalUnit": "degree",
"values": [
{
"timestamp": "2022-09-20T12:00:00.000Z",
"value": 259.25930044716694,
"leadTimeHours": 6
},
{
"timestamp": "2022-09-20T13:00:00.000Z",
"value": 259.7097466200864,
"leadTimeHours": 7
},
{
"timestamp": "2022-09-20T14:00:00.000Z",
"value": 260.1601927930058,
"leadTimeHours": 8
}
]
}
]
}

Retrieve forecast data for multiple variables (Python)

1
import requests
2
3
params = {
4
'token': 'YOUR_API_TOKEN',
5
'longitude': -152.0001,
6
'latitude': 37.0001,
7
'variableIDs': ['significantWaveHeight', 'meanDirection']
8
}
9
10
response = requests.get(
11
url='https://api.sofarocean.com/marine-weather/v1/models/Wave/forecast/point',
12
params=params
13
)
14
15
data = response.json()
16
print(data)
{
"modelID": "Wave",
"requestTime": "2022-09-20T19:28:01.701Z",
"requestLocation": {
"latitude": 37.0001,
"longitude": -152.0001
},
"forecastVariables": [
{
"variableID": "Wave-significantWaveHeight",
"variableName": "significantWaveHeight",
"physicalUnit": "m",
"values": [
{
"timestamp": "2022-09-20T12:00:00.000Z",
"value": 1.6149866487045847,
"leadTimeHours": 6
},
{
"timestamp": "2022-09-20T13:00:00.000Z",
"value": 1.6202169881441968,
"leadTimeHours": 7
},
{
"timestamp": "2022-09-20T14:00:00.000Z",
"value": 1.6205206852729486,
"leadTimeHours": 8
}
]
},
{
"variableID": "Wave-meanDirection",
"variableName": "meanDirection",
"physicalUnit": "degree",
"values": [
{
"timestamp": "2022-09-20T12:00:00.000Z",
"value": 259.25930044716694,
"leadTimeHours": 6
},
{
"timestamp": "2022-09-20T13:00:00.000Z",
"value": 259.7097466200864,
"leadTimeHours": 7
},
{
"timestamp": "2022-09-20T14:00:00.000Z",
"value": 260.1601927930058,
"leadTimeHours": 8
}
]
}
]
}