Openweathermap API 获取当天的高温和低温

Openweathermap API get HIGH and LOW temperature of the day

我正在开发一个 android 应用程序,我需要我所在城市的当前天气及其 low/high 温度。有没有办法获取当前的高温和低温我所在的城市?

我发现有 min/max 温度,但我认为这不是我要找的。如果 openweathermap 没有 low/high temp,有没有办法从它的数据中手动找到它?

"Please, do not confuse min/max parameters in current weather API and forecast API. In current weather API temp_min and temp_max are optional parameters mean min / max temperature in the city at the current moment to see deviation from current temp just for your reference. For large cities and megalopolises geographically expanded it might be applicable. In most cases both temp_min and temp_max parameters have the same volume as 'temp'. Please, use temp_min and temp_max parameters in current weather API optionally."

对于 OpenWeatherMap 的当前天气 API,最高和最低温度基于当前温度。这意味着如果温度为 70 度,则最小值可能为 69 度,最大值为 71 度。最小值和最大值只是给出当时的温度范围,而不是一整天。您必须使用另一个 API(预测 API)来获取整日的最低和最高温度。

进一步了解@SonneyStarPLUS 所说的(来自他们的网站):

请不要在我们的天气 API 中混淆 min/max 参数。

在每小时预报 API 中,当前天气 API 和 5 天/3 小时预报 API - temp_min 和 temp_max 是可选参数 mean min / 当前城市的最高温度,以查看与当前温度的偏差,仅供您参考。对于地理上扩展的大城市和特大城市,它可能适用。在大多数情况下,temp_min 和 temp_max 参数与 'temp' 的音量相同。请在当前天气 API 中选择性地使用 temp_min 和 temp_max 参数。 在 16 天预报中 - 一天中的最低和最高平均最高和最低温度。

If openweathermap doesn't have low/high temp, is there a way I can find it manually from its data?

如果您使用的是免费的 OpenWeatherMap 计划

您可以使用来自 5 days/3 hour forecast API:

的 24 小时数据来估算每天的 minimum/maximum 温度
  1. 根据需要调用 API。
  2. 迭代前 8 个三小时 list 记录,捕获 main.temp 并跟踪所见的最低和最高值。

实际的最低 and/or 最高温度可能出现在两个读数的中点附近;因此,上述计算结果可能略有偏差。尽管如此,这种方法已经足够满足我的实践需求了。

如果您使用的是任何付费的 OpenWeatherMap 计划

您可以从 daily forecast API 获取每日 minimum/maximum 温度。