Obtener historial por hora

El extremo history.hours muestra hasta 24 horas de datos históricos meteorológicos por hora en una ubicación determinada, a partir de la última hora. La API muestra lo siguiente:

  • Una descripción de las condiciones climáticas con el ícono correspondiente para una hora determinada
  • Temperaturas máximas y mínimas diarias
  • Temperaturas aparentes máximas y mínimas diarias ("sensación térmica")
  • Punto de condensación
  • Índice de calor
  • Temperatura de la bombilla húmeda
  • Humedad relativa
  • Índice UV
  • Probabilidad, porcentaje, cantidad y tipo de precipitación
  • Probabilidad de tormentas eléctricas
  • Presión al nivel del mar
  • Sensación térmica
  • Dirección, velocidad y ráfagas del viento
  • Grosor del hielo
  • Visibilidad y cobertura de nubes

Acerca de las solicitudes de historial por hora

Para solicitar información del historial por hora, envía una solicitud GET de HTTP a:

https://weather.googleapis.com/v1/history/hours:lookup?key=YOUR_API_KEY&location.latitude=LATITUDE&location.longitude=LONGITUDE

Incluye las coordenadas de latitud y longitud de la ubicación en los parámetros de la URL de tu solicitud.

Ejemplos de solicitudes de historial por hora

De forma predeterminada, el extremo history.hours muestra 24 horas de datos meteorológicos históricos, a partir de la última hora. Puedes definir el permiso de tu solicitud para un período determinado con el parámetro hours.

En el siguiente ejemplo, se solicita información del historial por hora de las últimas tres horas en Mountain View, California:

curl -X GET "https://weather.googleapis.com/v1/history/hours:lookup?key=YOUR_API_KEY&location.latitude=37.4220&location.longitude=-122.0841&hours=3"

En la respuesta, el objeto interval indica cada hora de información:

{
  "historyHours": [
    {
      "interval": {
        "startTime": "2025-02-12T22:00:00Z",
        "endTime": "2025-02-12T23:00:00Z"
      },
      "displayDateTime": {
        "year": 2025,
        "month": 2,
        "day": 12,
        "hours": 14,
        "utcOffset": "-28800s"
      },
      "isDaytime": true,
      "weatherCondition": {
        "iconBaseUri": "https://maps.gstatic.com/weather/v1/cloudy",
        "description": {
          "text": "Cloudy",
          "languageCode": "en"
        },
        "type": "CLOUDY"
      },
      "temperature": {
        "degrees": 12.4,
        "unit": "CELSIUS"
      },
      "feelsLikeTemperature": {
        "degrees": 12.4,
        "unit": "CELSIUS"
      },
      "dewPoint": {
        "degrees": 6.1,
        "unit": "CELSIUS"
      },
      "heatIndex": {
        "degrees": 12.4,
        "unit": "CELSIUS"
      },
      "windChill": {
        "degrees": 12.4,
        "unit": "CELSIUS"
      },
      "wetBulbTemperature": {
        "degrees": 9.1,
        "unit": "CELSIUS"
      },
      "relativeHumidity": 65,
      "uvIndex": 1,
      "precipitation": {
        "probability": {
          "percent": 10,
          "type": "RAIN"
        },
        "qpf": {
          "quantity": 0,
          "unit": "MILLIMETERS"
        }
      },
      "thunderstormProbability": 0,
      "airPressure": {
        "meanSeaLevelMillibars": 1010.4
      },
      "wind": {
        "direction": {
          "degrees": 135,
          "cardinal": "SOUTHEAST"
        },
        "speed": {
          "value": 3,
          "unit": "KILOMETERS_PER_HOUR"
        },
        "gust": {
          "value": 6,
          "unit": "KILOMETERS_PER_HOUR"
        }
      },
      "visibility": {
        "distance": 16,
        "unit": "KILOMETERS"
      },
      "cloudCover": 95,
      "iceThickness": {
        "thickness": 0,
        "unit": "MILLIMETERS"
      }
    },
    {
      "interval": {
        "startTime": "2025-02-12T21:00:00Z",
        "endTime": "2025-02-12T22:00:00Z"
      },
      "displayDateTime": {
        "year": 2025,
        "month": 2,
        "day": 12,
        "hours": 13,
        "utcOffset": "-28800s"
      },
      "isDaytime": true,
      "weatherCondition": {
        "iconBaseUri": "https://maps.gstatic.com/weather/v1/cloudy",
        "description": {
          "text": "Cloudy",
          "languageCode": "en"
        },
        "type": "CLOUDY"
      },
      /.../
    },
    {
      "interval": {
        "startTime": "2025-02-12T20:00:00Z",
        "endTime": "2025-02-12T21:00:00Z"
      },
      "displayDateTime": {
        "year": 2025,
        "month": 2,
        "day": 12,
        "hours": 12,
        "utcOffset": "-28800s"
      },
      "isDaytime": true,
      "weatherCondition": {
        "iconBaseUri": "https://maps.gstatic.com/weather/v1/cloudy",
        "description": {
          "text": "Cloudy",
          "languageCode": "en"
        },
        "type": "CLOUDY"
      },
      /.../
    }
  ],
  "timeZone": {
    "id": "America/Los_Angeles"
  }
}

Especifica la cantidad de horas que se mostrarán por página

Puedes especificar la cantidad de horas de datos que se muestran por página con el parámetro de URL pageSize. El valor predeterminado es de 24 horas de información del pronóstico por página.

Las respuestas con varias páginas de información incluyen un nextPageToken. Para ver la siguiente página de información, pasa el valor nextPageToken al parámetro pageToken en tu solicitud.

En el siguiente ejemplo, se solicitan ocho horas de datos del pronóstico del clima para Mountain View, California, con cinco horas de datos por página:

curl -X GET "https://weather.googleapis.com/v1/history/hours:lookup?key=YOUR_API_KEY&location.latitude=37.4220&location.longitude=-122.0841&hours=8&pageSize=5"

La respuesta, que incluye las primeras tres horas de datos, tiene el siguiente formato:

{
  "historyHours": [
    {
      "interval": {
        "startTime": "2025-02-12T23:00:00Z",
        "endTime": "2025-02-13T00:00:00Z"
      },
      "displayDateTime": {
        "year": 2025,
        "month": 2,
        "day": 12,
        "hours": 15,
        "utcOffset": "-28800s"
      },
      "isDaytime": true,
      "weatherCondition": {
        "iconBaseUri": "https://maps.gstatic.com/weather/v1/cloudy",
        "description": {
          "text": "Cloudy",
          "languageCode": "en"
        },
        "type": "CLOUDY"
      },
      "temperature": {
        "degrees": 11.6,
        "unit": "CELSIUS"
      },
      "feelsLikeTemperature": {
        "degrees": 11.6,
        "unit": "CELSIUS"
      },
      "dewPoint": {
        "degrees": 6.3,
        "unit": "CELSIUS"
      },
      "heatIndex": {
        "degrees": 11.6,
        "unit": "CELSIUS"
      },
      "windChill": {
        "degrees": 11.6,
        "unit": "CELSIUS"
      },
      "wetBulbTemperature": {
        "degrees": 8.8,
        "unit": "CELSIUS"
      },
      "relativeHumidity": 70,
      "uvIndex": 0,
      "precipitation": {
        "probability": {
          "percent": 10,
          "type": "RAIN"
        },
        "qpf": {
          "quantity": 0,
          "unit": "MILLIMETERS"
        }
      },
      "thunderstormProbability": 0,
      "airPressure": {
        "meanSeaLevelMillibars": 1010.07
      },
      "wind": {
        "direction": {
          "degrees": 65,
          "cardinal": "EAST_NORTHEAST"
        },
        "speed": {
          "value": 5,
          "unit": "KILOMETERS_PER_HOUR"
        },
        "gust": {
          "value": 10,
          "unit": "KILOMETERS_PER_HOUR"
        }
      },
      "visibility": {
        "distance": 16,
        "unit": "KILOMETERS"
      },
      "cloudCover": 95,
      "iceThickness": {
        "thickness": 0,
        "unit": "MILLIMETERS"
      }
    },
    {
      "interval": {
        "startTime": "2025-02-12T22:00:00Z",
        "endTime": "2025-02-12T23:00:00Z"
      },
      "displayDateTime": {
        "year": 2025,
        "month": 2,
        "day": 12,
        "hours": 14,
        "utcOffset": "-28800s"
      },
      "isDaytime": true,
      "weatherCondition": {
        "iconBaseUri": "https://maps.gstatic.com/weather/v1/cloudy",
        "description": {
          "text": "Cloudy",
          "languageCode": "en"
        },
        "type": "CLOUDY"
      },
      /.../
    },
    {
      "interval": {
        "startTime": "2025-02-12T21:00:00Z",
        "endTime": "2025-02-12T22:00:00Z"
      },
      "displayDateTime": {
        "year": 2025,
        "month": 2,
        "day": 12,
        "hours": 13,
        "utcOffset": "-28800s"
      },
      "isDaytime": true,
      "weatherCondition": {
        "iconBaseUri": "https://maps.gstatic.com/weather/v1/cloudy",
        "description": {
          "text": "Cloudy",
          "languageCode": "en"
        },
        "type": "CLOUDY"
      },
      /.../
    },
    {
      "interval": {
        "startTime": "2025-02-12T20:00:00Z",
        "endTime": "2025-02-12T21:00:00Z"
      },
      "displayDateTime": {
        "year": 2025,
        "month": 2,
        "day": 12,
        "hours": 12,
        "utcOffset": "-28800s"
      },
      "isDaytime": true,
      "weatherCondition": {
        "iconBaseUri": "https://maps.gstatic.com/weather/v1/cloudy",
        "description": {
          "text": "Cloudy",
          "languageCode": "en"
        },
        "type": "CLOUDY"
      },
      /.../
    },
    {
      "interval": {
        "startTime": "2025-02-12T19:00:00Z",
        "endTime": "2025-02-12T20:00:00Z"
      },
      "displayDateTime": {
        "year": 2025,
        "month": 2,
        "day": 12,
        "hours": 11,
        "utcOffset": "-28800s"
      },
      "isDaytime": true,
      "weatherCondition": {
        "iconBaseUri": "https://maps.gstatic.com/weather/v1/cloudy",
        "description": {
          "text": "Cloudy",
          "languageCode": "en"
        },
        "type": "CLOUDY"
      },
      /.../
    }
  ],
  "timeZone": {
    "id": "America/Los_Angeles"
  },
  "nextPageToken": "ChYKEgm8dJMYBLZCQL0xvc19BbmdlbGVz"
}

Para acceder a la siguiente página de datos, pasa el valor nextPageToken al parámetro pageToken en tu solicitud:

curl -X GET "https://weather.googleapis.com/v1/history/hours:lookup?key=YOUR_API_KEY&location.latitude=37.4220&location.longitude=-122.0841&hours=8&pageSize=5&pageToken=ChYKEgm8dJMYBLZCQL0xvc19BbmdlbGVz"

La respuesta tiene el siguiente formato:

{
  "historyHours": [
    {
      "interval": {
        "startTime": "2025-02-12T18:00:00Z",
        "endTime": "2025-02-12T19:00:00Z"
      },
      "displayDateTime": {
        "year": 2025,
        "month": 2,
        "day": 12,
        "hours": 10,
        "utcOffset": "-28800s"
      },
      "isDaytime": true,
      "weatherCondition": {
        "iconBaseUri": "https://maps.gstatic.com/weather/v1/cloudy",
        "description": {
          "text": "Cloudy",
          "languageCode": "en"
        },
        "type": "CLOUDY"
      },
      "temperature": {
        "degrees": 8.9,
        "unit": "CELSIUS"
      },
      "feelsLikeTemperature": {
        "degrees": 8.9,
        "unit": "CELSIUS"
      },
      "dewPoint": {
        "degrees": 5.9,
        "unit": "CELSIUS"
      },
      "heatIndex": {
        "degrees": 8.9,
        "unit": "CELSIUS"
      },
      "windChill": {
        "degrees": 8.9,
        "unit": "CELSIUS"
      },
      "wetBulbTemperature": {
        "degrees": 7.3,
        "unit": "CELSIUS"
      },
      "relativeHumidity": 82,
      "uvIndex": 1,
      "precipitation": {
        "probability": {
          "percent": 10,
          "type": "RAIN"
        },
        "qpf": {
          "quantity": 0,
          "unit": "MILLIMETERS"
        }
      },
      "thunderstormProbability": 0,
      "airPressure": {
        "meanSeaLevelMillibars": 1012.1
      },
      "wind": {
        "direction": {
          "degrees": 135,
          "cardinal": "SOUTHEAST"
        },
        "speed": {
          "value": 3,
          "unit": "KILOMETERS_PER_HOUR"
        },
        "gust": {
          "value": 8,
          "unit": "KILOMETERS_PER_HOUR"
        }
      },
      "visibility": {
        "distance": 16,
        "unit": "KILOMETERS"
      },
      "cloudCover": 100,
      "iceThickness": {
        "thickness": 0,
        "unit": "MILLIMETERS"
      }
    },
    {
      "interval": {
        "startTime": "2025-02-12T17:00:00Z",
        "endTime": "2025-02-12T18:00:00Z"
      },
      "displayDateTime": {
        "year": 2025,
        "month": 2,
        "day": 12,
        "hours": 9,
        "utcOffset": "-28800s"
      },
      "isDaytime": true,
      "weatherCondition": {
        "iconBaseUri": "https://maps.gstatic.com/weather/v1/cloudy",
        "description": {
          "text": "Cloudy",
          "languageCode": "en"
        },
        "type": "CLOUDY"
      },
      /.../
    },
    {
      "interval": {
        "startTime": "2025-02-12T16:00:00Z",
        "endTime": "2025-02-12T17:00:00Z"
      },
      "displayDateTime": {
        "year": 2025,
        "month": 2,
        "day": 12,
        "hours": 8,
        "utcOffset": "-28800s"
      },
      "isDaytime": true,
      "weatherCondition": {
        "iconBaseUri": "https://maps.gstatic.com/weather/v1/cloudy",
        "description": {
          "text": "Cloudy",
          "languageCode": "en"
        },
        "type": "CLOUDY"
      },
      /.../
    }
  ],
  "timeZone": {
    "id": "America/Los_Angeles"
  }
}