Products, help and information

The JSON feed

The meteoblue forecast and history API data packages can be called as CSV files or JSON feed. JSON (JavaScript Object Notation) is a human and machine readable data format similar to XML, but with some advantages compared to it. Since it became a language-independent and popular standard, parsing it is easily done in many programming languages.

Format example for a 7-day forecast from basic-day for Basel

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{ 
    "metadata": 
    { 
        "name": "Basel", 
        "latitude": 47.56, 
        "longitude": 7.57, 
        "height": 279, 
        "timezone_abbrevation": "CEST", 
        "utc_timeoffset": 2.00, 
        "modelrun_utc": "2018-10-26T00:00+02:00", 
        "modelrun_updatetime_utc": "2018-10-26T07:41+02:00" 
    }, 
    "units": 
    { 
        "time": "ISO8601", 
        "predictability": "percent", 
        "precipitation_probability": "percent", 
        "pressure": "hPa", 
        "relativehumidity": "percent", 
        "temperature": "C", 
        "precipitation": "mm", 
        "windspeed": "ms-1", 
        "winddirection": "degree" 
    }, 
    "trend_day": 
    { 
        "time": ["2018-10-26T00:00+02:00", "2018-10-27T00:00+02:00", "2018-10-28T00:00+02:00", "2018-10-29T00:00+02:00", "2018-10-30T00:00+02:00", "2018-10-31T00:00+02:00", "2018-11-01T00:00+02:00", "2018-11-02T00:00+02:00", "2018-11-03T00:00+02:00", "2018-11-04T00:00+02:00", "2018-11-05T00:00+02:00", "2018-11-06T00:00+02:00", "2018-11-07T00:00+02:00", "2018-11-08T00:00+02:00", "2018-11-09T00:00+02:00", "2018-11-10T00:00+02:00"], 
        "pictocode": [3, 12, 12, 4, 16, 1, 3, 4, 2, 1, 2, 1, 1, 1, 1, 1], 
        "temperature_max": [13.90, 9.88, 6.08, 6.68, 9.22, 14.43, 15.68, 16.92, 13.33, 13.67, 13.83, 13.44, 13.11, 12.16, 11.41, 10.98], 
        "temperature_min": [8.40, 5.30, 3.75, 3.01, 3.28, 1.91, 6.30, 4.15, 6.16, 5.78, 6.23, 5.38, 4.82, 3.58, 3.36, 2.66], 
        "temperature_mean": [10.48, 7.41, 4.82, 4.45, 5.58, 7.31, 9.78, 8.95, 8.90, 8.84, 9.01, 8.45, 7.92, 6.85, 6.31, 5.77], 
        "temperature_spread": [0.52, 0.55, 0.83, 1.58, 1.71, 2.24, 1.90, 1.86, 2.22, 2.19, 2.08, 2.50, 2.12, 2.40, 2.59, 3.05], 
        "precipitation": [0.00, 9.96, 11.22, 0.00, 2.56, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00], 
        "precipitation_probability": [0, 99, 99, 26, 51, 6, 18, 16, 16, 14, 16, 12, 10, 12, 8, 3], 
        "precipitation_spread": [0.00, 0.80, 2.20, 1.00, 2.10, 1.50, 0.90, 1.30, 0.72, 0.00, 1.20, 1.52, 0.60, 0.33, 1.08, 0.20], 
        "windspeed_max": [3.21, 3.94, 4.04, 3.44, 6.34, 4.68, 2.06, 2.80, 1.24, 1.12, 1.04, 1.36, 1.49, 1.15, 1.24, 1.13], 
        "windspeed_min": [0.61, 0.56, 1.25, 1.24, 2.64, 1.44, 0.52, 0.60, 0.36, 0.16, 0.06, 0.10, 0.20, 0.44, 0.12, 0.08], 
        "windspeed_mean": [1.71, 2.46, 2.74, 2.15, 4.89, 2.91, 1.31, 1.60, 0.83, 0.64, 0.64, 0.82, 0.85, 0.76, 0.63, 0.63], 
        "windspeed_spread": [0.45, 0.94, 1.78, 4.67, 4.46, 2.62, 1.92, 3.41, 3.00, 2.06, 1.72, 2.26, 2.19, 1.98, 2.06, 2.12], 
        "winddirection": [270, 315, 90, 0, 225, 135, 135, 135, 180, 135, 135, 135, 135, 90, 135, 135], 
        "sealevelpressure_max": [1016, 1009, 1005, 1003, 1009, 1011, 1020, 1022, 1023, 1023, 1022, 1023, 1024, 1024, 1024, 1023], 
        "sealevelpressure_min": [1008, 1006, 1001, 983, 982, 1006, 1011, 1020, 1022, 1021, 1021, 1022, 1023, 1023, 1022, 1021], 
        "sealevelpressure_mean": [1012, 1008, 1004, 995, 998, 1008, 1017, 1021, 1022, 1022, 1021, 1023, 1023, 1024, 1023, 1022], 
        "relativehumidity_max": [99, 92, 91, 94, 93, 92, 98, 98, 91, 91, 91, 90, 90, 90, 89, 88], 
        "relativehumidity_min": [53, 75, 79, 77, 48, 52, 64, 61, 59, 57, 58, 56, 54, 55, 53, 53], 
        "relativehumidity_mean": [78, 83, 86, 88, 74, 74, 83, 83, 78, 77, 78, 77, 76, 76, 75, 74], 
        "snowfraction": [0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00], 
        "predictability": [75, 62, 53, 53, 34, 59, 50, 52, 50, 55, 57, 57, 59, 56, 53, 47], 
        "predictability_class": [4, 4, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3], 
        "totalcloudcover_max": [100, 100, 100, 100, 100, 100, 100, 100, 53, 22, 30, 0, 0, 0, 0, 6], 
        "totalcloudcover_min": [7, 97, 100, 100, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0], 
        "totalcloudcover_mean": [76, 100, 100, 100, 54, 33, 70, 50, 25, 11, 9, 0, 0, 0, 0, 0], 
        "totalcloudcover_spread": [14, 5, 15, 32, 32, 30, 32, 40, 38, 32, 30, 29, 28, 25, 25, 28] 
    } 
}

PHP usage example for our API JSON data feed

Our API is easy to use. All you have to do is download the forecast via HTTP and parse the JSON formatted result. In PHP, this only needs two lines of code.
Example for Basel at coordinates 47.56°N and 7.6°E and on 263m above sea level:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
/* Download and parse data for Basel (47.5667°/7.6° 263m asl) */ 
$url = "http://my.meteoblue.com/packages/basic-day?...&lat=47.5667&lon=7.6&asl=263";
$raw = file_get_contents($url);
$weather = json_decode($raw);

/* Print max temperature of today in Basel */
echo "Max temperature today in Basel: {$weather->data_day->temperature_max->0}";

/* Print 7 day max temperature forecast */
foreach($weather->data_day as $day) {
    echo "Temperature on {$day->date} = {$day->temperature_max}";
}