Forecast API quick start
Everything you need to make your first request: how your key works, how to choose a hill, what comes back and the rules for showing it.
How your key works
Your key works like a password. Send it with each request in a header called X-Mountain-Weather-Key. A header is a short label that travels with the request rather than in the web address.
Requests must come from your own server, not from code running in visitors' browsers, where anyone could copy the key. A common pattern is for your server to fetch the forecast, keep a copy for a while, and include it in your own pages.
Choosing a hill
Each hill has an id. It's the last part of the hill's Mountain Weather page address: mountainweather.co.uk/mountain-forecast/ben-nevis is ben-nevis. For the full list of hill ids, names, heights and positions, request https://api.mountainweather.co.uk/v1/peak-index with your key.
Try your key
Paste your key and a hill id to see a real response without writing any code. Your key is used for this one request and is not stored.
Making a request
One hill's forecast is a single request. From a command line:
curl -H "X-Mountain-Weather-Key: YOUR_KEY" \
"https://api.mountainweather.co.uk/v1/peak?id=ben-nevis"
On a PHP server, this function fetches a hill's forecast and keeps it for an hour, so repeat visits don't need a new request. Put your key in place of YOUR_KEY, or set it as a MOUNTAIN_WEATHER_API_KEY environment variable.
<?php
// Returns the three-day forecast for one hill, e.g. mountain_weather_forecast('ben-nevis').
// Keep this file on your server: your key must never be sent to visitors' browsers.
function mountain_weather_forecast(string $hillId): ?array
{
$key = getenv('MOUNTAIN_WEATHER_API_KEY') ?: 'YOUR_KEY';
if (!preg_match('/^[a-z0-9-]{2,80}$/', $hillId)) return null;
// Reuse each hill's forecast for an hour (the terms allow up to six).
$cache = sys_get_temp_dir() . '/mountain-weather-' . $hillId . '.json';
if (is_file($cache) && filemtime($cache) > time() - 3600) {
return json_decode(file_get_contents($cache), true);
}
$context = stream_context_create(['http' => [
'header' => "X-Mountain-Weather-Key: $key\r\n",
'ignore_errors' => true,
'timeout' => 20,
]]);
$body = file_get_contents('https://api.mountainweather.co.uk/v1/peak?id=' . $hillId, false, $context);
if ($body === false || !preg_match('/^HTTP\/\S+ 200/', $http_response_header[0] ?? '')) return null;
file_put_contents($cache, $body);
return json_decode($body, true);
}
Any language that can send a web request with a header works the same way.
What comes back
A JSON summary for today and the next two days. Each day has:
hill_weather: the Mountain Weather score out of 100, its label and a short written outlook;summit_views: the chance of clear summit views, as a score with an outlook;headline,confidenceandconditions: rounded summit wind, gusts, feels-like temperature, rain, cloud base and freezing level;daylight: sunrise and sunset.
Every response also includes credit, with the link you must show, and a planning notice. Here is the first day of today's Ben Nevis response:
{
"ok": true,
"schema": "mountain-weather-community-summary-v1",
"peak": {
"id": "ben-nevis",
"name": "Ben Nevis",
"height_m": 1345
},
"issued_utc": "2026-11-25T16:33:47Z",
"forecast_status": "current",
"stale": false,
"days": [
{
"date": "2026-11-25",
"headline": "A poor day on the tops of Ben Nevis, with snow on the tops and cloud coming and going on the summit.",
"hill_weather": {
"score": 40,
"label": "Poor",
"outlook": "A poor day on the tops of Ben Nevis, with snow on the tops and cloud coming and going on the summit. Snow is forecast on the tops during the morning and afternoon. Burns could rise quickly from the morning into the afternoon. Snow for much of the day, turning lighter later. Things could still change through the day, so keep an eye on the sky."
},
"summit_views": {
"score": 7,
"outlook": "The tops are likely to drift in and out of cloud, with the best chance of a clear summit around midday. A few forecast models bring the cloud base down to around 500–800 m at times."
},
"confidence": "medium",
"conditions": {
"summit_wind": "5-15 mph",
"gusts": "10-20 mph",
"feels_like": "-12 to -8°C",
"rain": "Around 2-5 mm",
"freezing_level": "700-1,000 m",
"wind_direction": "S"
},
"daylight": {
"sunrise": "08:20",
"sunset": "15:53"
}
}
],
"credit": {
"required": true,
"text": "Forecast by Mountain Weather",
"url": "https://mountainweather.co.uk/mountain-forecast/ben-nevis"
},
"notice": "Planning guidance only. Mountain weather can differ from any forecast; it is not a guarantee of conditions or safety.",
"api_access": {
"plan": "community",
"forecast_days": 3,
"scope": "single named hill",
"terms": "https://mountainweather.co.uk/forecast-api/terms"
}
} If something goes wrong you'll receive a JSON error: 401 for a missing or unrecognised key, 403 for something your plan doesn't include, 404 for an unknown hill and 429 if requests come too quickly.
Using the forecast
- Show the forecast for one hill at a time, on that hill's own page, card or panel. It may not be shown on maps, or in lists, rankings or comparisons between hills.
- Show a visible "Forecast by Mountain Weather" link to the
credit.urladdress with each forecast. - You may keep responses on your server for up to six hours. Don't keep any copy more than 24 hours after it was issued.
- Forecasts are planning guidance, not guarantees. Keep the notice that comes with them.
The full rules are in the Forecast API terms. Questions: simon@mountainweather.co.uk.