Прогноз погоды

API Яндекс Погоды может предоставлять данные о прогнозе погоды как с детализацией по часам, так и агрегировано по частям дня. Детальный почасовой прогноз хорошо подойдет для отображения графика изменения погодного параметра, обнаружения важных изменений и анализа погодных данных. В то же время агрегированный прогноз по частям дня отлично подойдет для отображения в интерфейсе или быстрой оценки общей картины дня.

Для получения прогноза погоды по выбранной географической точке в запросе укажите объект forecast:

{
  weatherByPoint(request: {lat: 52.37125, lon: 4.89388}) {
    forecast {
      ...
    }
  }
}

Почасовой прогноз

Для получения почасового прогноза в запросе к API Яндекс Погоды внутри объекта forecast.days укажите объект hours, вложенный в объект days. Чтобы указать, на сколько дней вперед вы хотели бы получить данные, используйте аргумент limit для объектов days.

Пример запроса:



{
  weatherByPoint(request: { lat: 52.37175, lon: 4.89358 }) {
    forecast {
      days(limit: 1) {
        hours {
          time
          temperature
          humidity
          pressure
          windSpeed
          windDirection
        }
      }
    }
  }
}
Ответ на запрос
{
  "data": {
    "weatherByPoint": {
      "forecast": {
        "days": [
          {
            "hours": [
              {
                "time": "2022-12-02T00:00:00+01:00",
                "temperature": 4,
                "humidity": 93,
                "pressure": 771,
                "windSpeed": 1.8,
                "windDirection": "NORTH_EAST"
              },
              {
                "time": "2022-12-02T01:00:00+01:00",
                "temperature": 4,
                "humidity": 93,
                "pressure": 771,
                "windSpeed": 2,
                "windDirection": "NORTH_EAST"
              },
              {
                "time": "2022-12-02T02:00:00+01:00",
                "temperature": 4,
                "humidity": 92,
                "pressure": 770,
                "windSpeed": 2.7,
                "windDirection": "NORTH_EAST"
              },
              {
                "time": "2022-12-02T03:00:00+01:00",
                "temperature": 3,
                "humidity": 93,
                "pressure": 770,
                "windSpeed": 2.9,
                "windDirection": "NORTH_EAST"
              },
              {
                "time": "2022-12-02T04:00:00+01:00",
                "temperature": 3,
                "humidity": 92,
                "pressure": 770,
                "windSpeed": 2.9,
                "windDirection": "NORTH_EAST"
              },
              {
                "time": "2022-12-02T05:00:00+01:00",
                "temperature": 3,
                "humidity": 91,
                "pressure": 770,
                "windSpeed": 2.5,
                "windDirection": "NORTH_EAST"
              },
              {
                "time": "2022-12-02T06:00:00+01:00",
                "temperature": 3,
                "humidity": 92,
                "pressure": 769,
                "windSpeed": 2.9,
                "windDirection": "NORTH_EAST"
              },
              {
                "time": "2022-12-02T07:00:00+01:00",
                "temperature": 3,
                "humidity": 90,
                "pressure": 769,
                "windSpeed": 3.5,
                "windDirection": "NORTH_EAST"
              },
              {
                "time": "2022-12-02T08:00:00+01:00",
                "temperature": 2,
                "humidity": 89,
                "pressure": 769,
                "windSpeed": 4.5,
                "windDirection": "NORTH_EAST"
              },
              {
                "time": "2022-12-02T09:00:00+01:00",
                "temperature": 2,
                "humidity": 87,
                "pressure": 769,
                "windSpeed": 4,
                "windDirection": "NORTH_EAST"
              },
              {
                "time": "2022-12-02T10:00:00+01:00",
                "temperature": 3,
                "humidity": 84,
                "pressure": 769,
                "windSpeed": 4.1,
                "windDirection": "NORTH_EAST"
              },
              {
                "time": "2022-12-02T11:00:00+01:00",
                "temperature": 3,
                "humidity": 85,
                "pressure": 769,
                "windSpeed": 5.6,
                "windDirection": "NORTH_EAST"
              },
              {
                "time": "2022-12-02T12:00:00+01:00",
                "temperature": 3,
                "humidity": 84,
                "pressure": 769,
                "windSpeed": 5,
                "windDirection": "NORTH_EAST"
              },
              {
                "time": "2022-12-02T13:00:00+01:00",
                "temperature": 3,
                "humidity": 83,
                "pressure": 768,
                "windSpeed": 5.4,
                "windDirection": "NORTH_EAST"
              },
              {
                "time": "2022-12-02T14:00:00+01:00",
                "temperature": 2,
                "humidity": 82,
                "pressure": 768,
                "windSpeed": 5.4,
                "windDirection": "NORTH_EAST"
              },
              {
                "time": "2022-12-02T15:00:00+01:00",
                "temperature": 2,
                "humidity": 84,
                "pressure": 768,
                "windSpeed": 5,
                "windDirection": "NORTH_EAST"
              },
              {
                "time": "2022-12-02T16:00:00+01:00",
                "temperature": 2,
                "humidity": 83,
                "pressure": 768,
                "windSpeed": 5.5,
                "windDirection": "NORTH_EAST"
              },
              {
                "time": "2022-12-02T17:00:00+01:00",
                "temperature": 3,
                "humidity": 82,
                "pressure": 769,
                "windSpeed": 4.5,
                "windDirection": "NORTH_EAST"
              },
              {
                "time": "2022-12-02T18:00:00+01:00",
                "temperature": 3,
                "humidity": 84,
                "pressure": 769,
                "windSpeed": 5,
                "windDirection": "NORTH_EAST"
              },
              {
                "time": "2022-12-02T19:00:00+01:00",
                "temperature": 3,
                "humidity": 82,
                "pressure": 769,
                "windSpeed": 6,
                "windDirection": "NORTH_EAST"
              },
              {
                "time": "2022-12-02T20:00:00+01:00",
                "temperature": 3,
                "humidity": 84,
                "pressure": 769,
                "windSpeed": 6,
                "windDirection": "NORTH_EAST"
              },
              {
                "time": "2022-12-02T21:00:00+01:00",
                "temperature": 3,
                "humidity": 84,
                "pressure": 769,
                "windSpeed": 6,
                "windDirection": "NORTH_EAST"
              },
              {
                "time": "2022-12-02T22:00:00+01:00",
                "temperature": 3,
                "humidity": 82,
                "pressure": 769,
                "windSpeed": 5.6,
                "windDirection": "NORTH_EAST"
              },
              {
                "time": "2022-12-02T23:00:00+01:00",
                "temperature": 3,
                "humidity": 80,
                "pressure": 769,
                "windSpeed": 5.5,
                "windDirection": "NORTH_EAST"
              }
            ]
          }
        ]
      }
    }
  }
}

Прогноз по частям дня

Для получения прогноза, агрегированного по дням, в объекте forecast необходимо указать объект days (в необязательном параметре limit можно указать, на сколько дней вперед нужен прогноз).
Внутри объекта days можно запросить данные, относящиеся ко всему дню. Например, время восхода и заката, а также отдельно данные по частям дня:

  • morning – агрегированный прогноз на утро,
  • day – агрегированный прогноз на день,
  • evening – агрегированный прогноз на вечер,
  • night – агрегированный прогноз на ночь.

Так же как и ранее, внутри объектов, определяющих запрошенную часть дня, необходимо указать, какие погодные параметры необходимы.

Пример запроса:



{
  weatherByPoint(request: { lat: 52.37125, lon: 4.89388 }) {
    forecast {
      days(limit: 2) {
        time
        sunriseTime
        sunsetTime
        parts {
          morning {
            avgTemperature
          }
          day {
            avgTemperature
          }
          evening {
            avgTemperature
          }
          night {
            avgTemperature
          }
        }
      }
    }
  }
}
Ответ на запрос
{
  "data": {
    "weatherByPoint": {
      "forecast": {
        "days": [
          {
            "time": "2022-09-06T00:00:00+02:00",
            "sunrise": "06:59",
            "sunset": "20:18",
            "parts": {
              "morning": {
                "avgTemperature": 19
              },
              "day": {
                "avgTemperature": 25
              },
              "evening": {
                "avgTemperature": 22
              },
              "night": {
                "avgTemperature": 19
              }
            }
          },
          {
            "time": "2022-09-07T00:00:00+02:00",
            "sunrise": "07:00",
            "sunset": "20:16",
            "parts": {
              "morning": {
                "avgTemperature": 17
              },
              "day": {
                "avgTemperature": 23
              },
              "evening": {
                "avgTemperature": 20
              },
              "night": {
                "avgTemperature": 18
              }
            }
          }
        ]
      }
    }
  }
}

Прогноз на определенной высоте

Чтобы получить прогноз для определенной высоты (например, на 100 метрах), используйте поля onHeight объекта ForecastHour. Будет подобрана наиболее приближенная к запросу высота.

Доступные высотные параметры:

  • облачность на низком, среднем, высоком ярусе и общая облачность в процентах,
  • температура на высоте 2, 100, 500 метров,
  • ветер на высоте 10, 100, 200 метров.

Пример запроса:



{
  weatherByPoint(request: { lat: 52.37125, lon: 4.89388 }) {
    forecast {
      days(limit: 1) {
        hours {
          temperature
          time
          humidity
          pressure
          windSpeed
          windDirection
          cloudinessOnHeight(height: 100) {
            cloudiness
            height
          }
          temperatureOnHeight(height: 100) {
            temperature
            height
          }
          windAngleOnHeight(height: 100) {
            windAngle
            height
          }
          windDirectionOnHeight(height: 100) {
            windDirection
            height
          }
          windSpeedOnHeight(height: 100) {
            windSpeed
            height
          }
        }
      }
    }
  }
}
Ответ на запрос
{
  "data": {
    "weatherByPoint": {
      "forecast": {
        "days": [
          {
            "hours": [
              {
                "temperature": 4,
                "time": "2023-04-27T00:00:00+02:00",
                "humidity": 86,
                "pressure": 766,
                "windSpeed": 1.7,
                "windDirection": "NORTH",
                "cloudinessOnHeight": {
                  "cloudiness": 17,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 6,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 33,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "NORTH_EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 3.9,
                  "height": 100
                }
              },
              {
                "temperature": 4,
                "time": "2023-04-27T01:00:00+02:00",
                "humidity": 86,
                "pressure": 766,
                "windSpeed": 1.7,
                "windDirection": "NORTH",
                "cloudinessOnHeight": {
                  "cloudiness": 7,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 6,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 46,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "NORTH_EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 3,
                  "height": 100
                }
              },
              {
                "temperature": 3,
                "time": "2023-04-27T02:00:00+02:00",
                "humidity": 89,
                "pressure": 766,
                "windSpeed": 1.5,
                "windDirection": "NORTH_EAST",
                "cloudinessOnHeight": {
                  "cloudiness": 0,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 6,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 65,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "NORTH_EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 2.5,
                  "height": 100
                }
              },
              {
                "temperature": 3,
                "time": "2023-04-27T03:00:00+02:00",
                "humidity": 91,
                "pressure": 767,
                "windSpeed": 1.6,
                "windDirection": "NORTH_EAST",
                "cloudinessOnHeight": {
                  "cloudiness": 0,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 6,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 90,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 2.7,
                  "height": 100
                }
              },
              {
                "temperature": 2,
                "time": "2023-04-27T04:00:00+02:00",
                "humidity": 94,
                "pressure": 767,
                "windSpeed": 1.6,
                "windDirection": "NORTH_EAST",
                "cloudinessOnHeight": {
                  "cloudiness": 0,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 6,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 110,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 3.2,
                  "height": 100
                }
              },
              {
                "temperature": 3,
                "time": "2023-04-27T05:00:00+02:00",
                "humidity": 93,
                "pressure": 766,
                "windSpeed": 1.7,
                "windDirection": "SOUTH_EAST",
                "cloudinessOnHeight": {
                  "cloudiness": 0,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 5,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 123,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "SOUTH_EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 4,
                  "height": 100
                }
              },
              {
                "temperature": 1,
                "time": "2023-04-27T06:00:00+02:00",
                "humidity": 93,
                "pressure": 766,
                "windSpeed": 1.7,
                "windDirection": "SOUTH_EAST",
                "cloudinessOnHeight": {
                  "cloudiness": 33,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 5,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 132,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "SOUTH_EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 4.4,
                  "height": 100
                }
              },
              {
                "temperature": 2,
                "time": "2023-04-27T07:00:00+02:00",
                "humidity": 92,
                "pressure": 766,
                "windSpeed": 1.7,
                "windDirection": "SOUTH_EAST",
                "cloudinessOnHeight": {
                  "cloudiness": 67,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 5,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 140,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "SOUTH_EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 4.8,
                  "height": 100
                }
              },
              {
                "temperature": 5,
                "time": "2023-04-27T08:00:00+02:00",
                "humidity": 87,
                "pressure": 766,
                "windSpeed": 2.2,
                "windDirection": "SOUTH_EAST",
                "cloudinessOnHeight": {
                  "cloudiness": 100,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 4,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 147,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "SOUTH_EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 5.3,
                  "height": 100
                }
              },
              {
                "temperature": 7,
                "time": "2023-04-27T09:00:00+02:00",
                "humidity": 77,
                "pressure": 766,
                "windSpeed": 2.7,
                "windDirection": "SOUTH_EAST",
                "cloudinessOnHeight": {
                  "cloudiness": 100,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 5,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 149,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "SOUTH_EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 4.8,
                  "height": 100
                }
              },
              {
                "temperature": 9,
                "time": "2023-04-27T10:00:00+02:00",
                "humidity": 67,
                "pressure": 766,
                "windSpeed": 2.9,
                "windDirection": "SOUTH_EAST",
                "cloudinessOnHeight": {
                  "cloudiness": 100,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 7,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 152,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "SOUTH_EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 4.4,
                  "height": 100
                }
              },
              {
                "temperature": 10,
                "time": "2023-04-27T11:00:00+02:00",
                "humidity": 58,
                "pressure": 766,
                "windSpeed": 3.4,
                "windDirection": "SOUTH_EAST",
                "cloudinessOnHeight": {
                  "cloudiness": 100,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 8,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 155,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "SOUTH_EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 3.9,
                  "height": 100
                }
              },
              {
                "temperature": 11,
                "time": "2023-04-27T12:00:00+02:00",
                "humidity": 52,
                "pressure": 766,
                "windSpeed": 3.7,
                "windDirection": "SOUTH_EAST",
                "cloudinessOnHeight": {
                  "cloudiness": 100,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 8,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 149,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "SOUTH_EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 3.7,
                  "height": 100
                }
              },
              {
                "temperature": 12,
                "time": "2023-04-27T13:00:00+02:00",
                "humidity": 50,
                "pressure": 766,
                "windSpeed": 4,
                "windDirection": "SOUTH_EAST",
                "cloudinessOnHeight": {
                  "cloudiness": 100,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 9,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 142,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "SOUTH_EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 3.5,
                  "height": 100
                }
              },
              {
                "temperature": 12,
                "time": "2023-04-27T14:00:00+02:00",
                "humidity": 49,
                "pressure": 766,
                "windSpeed": 3.2,
                "windDirection": "SOUTH_EAST",
                "cloudinessOnHeight": {
                  "cloudiness": 100,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 10,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 134,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "SOUTH_EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 3.5,
                  "height": 100
                }
              },
              {
                "temperature": 12,
                "time": "2023-04-27T15:00:00+02:00",
                "humidity": 48,
                "pressure": 766,
                "windSpeed": 3.5,
                "windDirection": "SOUTH_EAST",
                "cloudinessOnHeight": {
                  "cloudiness": 100,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 11,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 127,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "SOUTH_EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 3.9,
                  "height": 100
                }
              },
              {
                "temperature": 13,
                "time": "2023-04-27T16:00:00+02:00",
                "humidity": 45,
                "pressure": 766,
                "windSpeed": 3.5,
                "windDirection": "SOUTH_EAST",
                "cloudinessOnHeight": {
                  "cloudiness": 100,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 11,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 120,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "SOUTH_EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 4.4,
                  "height": 100
                }
              },
              {
                "temperature": 13,
                "time": "2023-04-27T17:00:00+02:00",
                "humidity": 46,
                "pressure": 765,
                "windSpeed": 3.4,
                "windDirection": "EAST",
                "cloudinessOnHeight": {
                  "cloudiness": 100,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 12,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 115,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "SOUTH_EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 4.9,
                  "height": 100
                }
              },
              {
                "temperature": 12,
                "time": "2023-04-27T18:00:00+02:00",
                "humidity": 50,
                "pressure": 765,
                "windSpeed": 3.7,
                "windDirection": "EAST",
                "cloudinessOnHeight": {
                  "cloudiness": 100,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 12,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 112,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 4.9,
                  "height": 100
                }
              },
              {
                "temperature": 12,
                "time": "2023-04-27T19:00:00+02:00",
                "humidity": 58,
                "pressure": 765,
                "windSpeed": 3.5,
                "windDirection": "EAST",
                "cloudinessOnHeight": {
                  "cloudiness": 100,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 11,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 109,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 4.9,
                  "height": 100
                }
              },
              {
                "temperature": 11,
                "time": "2023-04-27T20:00:00+02:00",
                "humidity": 61,
                "pressure": 763,
                "windSpeed": 3.2,
                "windDirection": "EAST",
                "cloudinessOnHeight": {
                  "cloudiness": 100,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 11,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 105,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 4.9,
                  "height": 100
                }
              },
              {
                "temperature": 11,
                "time": "2023-04-27T21:00:00+02:00",
                "humidity": 67,
                "pressure": 763,
                "windSpeed": 3.2,
                "windDirection": "EAST",
                "cloudinessOnHeight": {
                  "cloudiness": 100,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 10,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 101,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 5.8,
                  "height": 100
                }
              },
              {
                "temperature": 10,
                "time": "2023-04-27T22:00:00+02:00",
                "humidity": 70,
                "pressure": 763,
                "windSpeed": 3.2,
                "windDirection": "EAST",
                "cloudinessOnHeight": {
                  "cloudiness": 100,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 9,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 98,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 6.6,
                  "height": 100
                }
              },
              {
                "temperature": 10,
                "time": "2023-04-27T23:00:00+02:00",
                "humidity": 68,
                "pressure": 762,
                "windSpeed": 3.2,
                "windDirection": "EAST",
                "cloudinessOnHeight": {
                  "cloudiness": 100,
                  "height": 100
                },
                "temperatureOnHeight": {
                  "temperature": 9,
                  "height": 100
                },
                "windAngleOnHeight": {
                  "windAngle": 96,
                  "height": 100
                },
                "windDirectionOnHeight": {
                  "windDirection": "EAST",
                  "height": 100
                },
                "windSpeedOnHeight": {
                  "windSpeed": 7.5,
                  "height": 100
                }
              }
            ]
          }
        ]
      }
    }
  }
}

Прогноз для нескольких точек

В Graphql API есть возможность получить прогноз сразу для нескольких точек. Для этого необходимо создать фрагмент с объектом forecast, в котором будут указаны нужные данные. Созданный фрагмент указывается в вызове метода weatherByPoint для каждой точки.

Например, для точек Moscow, Petersburg и Kazan можно получить агрегированный дневной (day) и ночной (night) прогноз на 3 дня вперед по следующим параметрам:

  • cloudiness — облачность,
  • humidity — относительная влажность воздуха,
  • avgTemperature — средняя температура,
  • prec — количество осадков (в миллиметрах),
  • precType — тип осадков,
  • precStrength — интенсивность осадков,
  • windSpeed — скорость ветра,
  • windDirection — направление ветра.

Пример запроса:



{
  London: weatherByPoint(request: { lat: 51.50730, lon: -0.12769 }) {
    ...WeatherData
  }
  Warsaw: weatherByPoint(request: { lat: 52.23209, lon: 21.00714 }) {
    ...WeatherData
  }
  Berlin: weatherByPoint(request: { lat: 52.51865, lon: 13.37471 }) {
    ...WeatherData
  }
}

fragment WeatherData on Weather {
  forecast {
    days(limit: 3) {
      summary {
        day {
          cloudiness
          humidity
          avgTemperature
          prec
          precType
          precStrength
          windSpeed
          windDirection
        }
        night {
          cloudiness
          humidity
          avgTemperature
          prec
          precType
          precStrength
          windSpeed
          windDirection
        }
      }
    }
  }
}
Ответ на запрос
{
  "data": {
    "London": {
      "forecast": {
        "days": [
          {
            "summary": {
              "day": {
                "cloudiness": "OVERCAST",
                "humidity": 87,
                "avgTemperature": 16,
                "prec": 40.4,
                "precType": "RAIN",
                "precStrength": "VERY_STRONG",
                "windSpeed": 3.4,
                "windDirection": "WEST"
              },
              "night": {
                "cloudiness": "OVERCAST",
                "humidity": 95,
                "avgTemperature": 14,
                "prec": 0.5,
                "precType": "RAIN",
                "precStrength": "WEAK",
                "windSpeed": 1.7,
                "windDirection": "SOUTH_WEST"
              }
            }
          },
          {
            "summary": {
              "day": {
                "cloudiness": "SIGNIFICANT",
                "humidity": 80,
                "avgTemperature": 17,
                "prec": 0,
                "precType": "NO_TYPE",
                "precStrength": "ZERO",
                "windSpeed": 2.5,
                "windDirection": "NORTH_WEST"
              },
              "night": {
                "cloudiness": "SIGNIFICANT",
                "humidity": 96,
                "avgTemperature": 14,
                "prec": 0,
                "precType": "NO_TYPE",
                "precStrength": "ZERO",
                "windSpeed": 1.7,
                "windDirection": "WEST"
              }
            }
          },
          {
            "summary": {
              "day": {
                "cloudiness": "OVERCAST",
                "humidity": 80,
                "avgTemperature": 18,
                "prec": 0,
                "precType": "NO_TYPE",
                "precStrength": "ZERO",
                "windSpeed": 2,
                "windDirection": "SOUTH"
              },
              "night": {
                "cloudiness": "CLEAR",
                "humidity": 93,
                "avgTemperature": 13,
                "prec": 0,
                "precType": "NO_TYPE",
                "precStrength": "ZERO",
                "windSpeed": 1.2,
                "windDirection": "NORTH_WEST"
              }
            }
          }
        ]
      }
    },
    "Warsaw": {
      "forecast": {
        "days": [
          {
            "summary": {
              "day": {
                "cloudiness": "OVERCAST",
                "humidity": 87,
                "avgTemperature": 14,
                "prec": 0.2,
                "precType": "RAIN",
                "precStrength": "WEAK",
                "windSpeed": 3.3,
                "windDirection": "EAST"
              },
              "night": {
                "cloudiness": "OVERCAST",
                "humidity": 81,
                "avgTemperature": 14,
                "prec": 0.4,
                "precType": "RAIN",
                "precStrength": "WEAK",
                "windSpeed": 4.5,
                "windDirection": "SOUTH_EAST"
              }
            }
          },
          {
            "summary": {
              "day": {
                "cloudiness": "OVERCAST",
                "humidity": 81,
                "avgTemperature": 15,
                "prec": 0.8,
                "precType": "RAIN",
                "precStrength": "WEAK",
                "windSpeed": 2.4,
                "windDirection": "NORTH_EAST"
              },
              "night": {
                "cloudiness": "CLOUDY",
                "humidity": 95,
                "avgTemperature": 12,
                "prec": 0,
                "precType": "NO_TYPE",
                "precStrength": "ZERO",
                "windSpeed": 1.8,
                "windDirection": "EAST"
              }
            }
          },
          {
            "summary": {
              "day": {
                "cloudiness": "OVERCAST",
                "humidity": 87,
                "avgTemperature": 13,
                "prec": 1.6,
                "precType": "RAIN",
                "precStrength": "WEAK",
                "windSpeed": 3,
                "windDirection": "NORTH_WEST"
              },
              "night": {
                "cloudiness": "OVERCAST",
                "humidity": 92,
                "avgTemperature": 13,
                "prec": 0.7,
                "precType": "RAIN",
                "precStrength": "WEAK",
                "windSpeed": 1.6,
                "windDirection": "NORTH_WEST"
              }
            }
          }
        ]
      }
    },
    "Berlin": {
      "forecast": {
        "days": [
          {
            "summary": {
              "day": {
                "cloudiness": "SIGNIFICANT",
                "humidity": 77,
                "avgTemperature": 18,
                "prec": 0.4,
                "precType": "RAIN",
                "precStrength": "WEAK",
                "windSpeed": 2.6,
                "windDirection": "EAST"
              },
              "night": {
                "cloudiness": "CLEAR",
                "humidity": 95,
                "avgTemperature": 14,
                "prec": 0,
                "precType": "NO_TYPE",
                "precStrength": "ZERO",
                "windSpeed": 2.1,
                "windDirection": "SOUTH"
              }
            }
          },
          {
            "summary": {
              "day": {
                "cloudiness": "SIGNIFICANT",
                "humidity": 79,
                "avgTemperature": 17,
                "prec": 0.2,
                "precType": "RAIN",
                "precStrength": "WEAK",
                "windSpeed": 2,
                "windDirection": "SOUTH_WEST"
              },
              "night": {
                "cloudiness": "CLEAR",
                "humidity": 93,
                "avgTemperature": 14,
                "prec": 0,
                "precType": "NO_TYPE",
                "precStrength": "ZERO",
                "windSpeed": 1.7,
                "windDirection": "SOUTH_EAST"
              }
            }
          },
          {
            "summary": {
              "day": {
                "cloudiness": "CLOUDY",
                "humidity": 85,
                "avgTemperature": 17,
                "prec": 0,
                "precType": "NO_TYPE",
                "precStrength": "ZERO",
                "windSpeed": 3.3,
                "windDirection": "NORTH_WEST"
              },
              "night": {
                "cloudiness": "CLOUDY",
                "humidity": 93,
                "avgTemperature": 14,
                "prec": 0,
                "precType": "NO_TYPE",
                "precStrength": "ZERO",
                "windSpeed": 1.3,
                "windDirection": "NORTH_WEST"
              }
            }
          }
        ]
      }
    }
  }
}