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"
Response
{
    "modelID": "Wave",
    "requestTime": "2022-09-20T19:26:45.812Z",
    "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
                }
    ]   
}

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"
Response

{
    "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)

import requests

params = {
    'token': 'YOUR_API_TOKEN',
    'longitude': -152.0001,
    'latitude': 37.0001,
    'variableIDs': ['significantWaveHeight', 'meanDirection']
}

response = requests.get(
    url='https://api.sofarocean.com/marine-weather/v1/models/Wave/forecast/point',
    params=params
)

data = response.json()
print(data)
Response
{
    "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
                }
            ]
        }
    ]
}

Last updated