OpenWeatherMap 获取当天的平均温度

OpenWeatherMap get average temperature on day

使用 openweathermap api 如何使用 javascript 获取某一天的平均温度。我知道我只能在接下来的 5 天内取得联系。我一直在寻找,但找不到一种方法来做到这一点,而且没有看到其他人这样做。

您可以利用 api api.openweathermap.org/data/2.5/forecast?q={city name},{country code}。详情请参考here

您可以按城市名称搜索每 3 小时一次数据的 5 天天气预报。所有天气数据可以JSON和XML格式获取。

https://openweathermap.org/forecast5

API call:

api.openweathermap.org/data/2.5/forecast?q={city name},{country code}

Parameters:

q city name and country code divided by comma, use ISO 3166 country codes

Examples of API calls:

api.openweathermap.org/data/2.5/forecast?q=London,us&mode=xml

如果你使用自由模式,你可以使用API这个>https://api.openweathermap.org/data/2.5/onecall?lat={lat}&lon={lon}&exclude={part}&appid={API键}

对于 'exclude',值为 'current'

你可以在结果中找到 'daily'

像下面这样,如果你使用免费模式,每天只有7天的数据

{“dt”:1616238000,“温度”:301.64,“feels_like”:305.49,“压力”:1006,“湿度”:72,“dew_point”:296.11, “uvi”:0.17,“云”:97,“能见度”:10000,“wind_speed”:1.94,“wind_deg”:25,“wind_gust”:4.14,“天气":[{"id":804,"main":"Clouds","description":"阴云密布","icon":"04d"}],"pop":0.39}],"daily":[{"dt":1616043600,"sunrise":1616023825,"sunset":1616067395,"temp":{"day":305.68,"min":296.48,"max": 305.68,"night":298.13,"eve":301.4,"morn":296.48},"feels_like":{"day":309.22,"night":302.32,"eve":306.11,"morn" ":300.23},"压力":1010,"湿度":55,"dew_point":295.34,"wind_speed":1.88,"wind_deg":2,"天气" :[{"id":500,"main":"Rain","description":"小雨","icon":"10d"}],"clouds":71,"pop":0.58,"rain ":1.88,"uvi":14.19},{"dt":1616130000,"sunrise":1616110201,"sunset":1616153783,"temp":{"day":305.38,"min":296.44,"max" :305.62,"night":298.19,"eve":301.52,"morn":296.44},"feels_like":{"day":308.32,"night":302.18,"eve":306.01," morn":300.25},"pressure":1010,"humidity":54,"dew_point":294.93,"wind_speed":2.3,"wind_deg":347,"weath er":[{"id":501,"main":"Rain","description":"中雨","icon":"10d"}],"clouds":5,"pop":0.94, "rain":4.71,"uvi":13.78},{"dt":1616216400,"sunrise":1616196576,"sunset":1616240170,"temp":{"day":305.82,"min":296.51," max":306.34,"night":298.41,"eve":301.64,"morn":296.51},"feels_like":{"day":308.58,"night":302.5,"eve":305.49 “早晨”:300.44},“压力”:1009,“湿度”:51,“dew_point”:294.26,“wind_speed”:2.17,“wind_deg”:349, "weather":[{"id":500,"main":"Rain","description":"小雨","icon":"10d"}],"clouds":93,"pop":0.4 “rain”:0.23,“uvi”:13.37},{“dt”:1616302800,“sunrise”:1616282952,“sunset”:1616326557,“temp”:{“day”:305.56,“min”:297.1, "max":305.56,"night":298.4,"eve":299.56,"morn":297.1},"feels_like":{"day":308.74,"night":303.18,"eve": 304.47,“早晨”:300.75},“压力”:1009,“湿度”:55,“dew_point”:295.3,“wind_speed”:2.31,“wind_deg”:339 "weather":[{"id":500,"main":"Rain","description":"小雨","icon":"10d"}],"clouds":88,"pop": 0.48,"rain":1.85,"uvi":13.47},{"dt":1616389200,"sunrise":1616369327,"sunset":1616412945,"te mp":{"day":306.08,"min":296.6,"max":306.08,"night":298.56,"eve":299.63,"morn":296.6},"feels_like":{ "day":309.2,"night":303.14,"eve":304.4,"morn":300.19},"pressure":1010,"humidity":52,"dew_point":294.84,"wind_speed":2.07,"wind_deg":13,"天气":[{"id":500,"main":"Rain","description":"小雨","icon": "10d"}],"clouds":98,"pop":0.67,"rain":3.8,"uvi":14},{"dt":1616475600,"sunrise":1616455702,"sunset":1616499332, “temp”:{“day”:307.01,“min”:296.67,“max”:307.01,“night”:298.42,“eve”:299.71,“morn”:296.79},“feels_like”: {"day":310.15,"night":303.02,"eve":304.13,"morn":300.55},"pressure":1009,"humidity":48,"dew_point":294.56," =29=]":1.7,"wind_deg":21,"天气":[{"id":501,"main":"Rain","description":"中雨","icon" :"10d"}],"clouds":87,"pop":0.94,"rain":11.17,"uvi":14},{"dt":1616562000,"sunrise":1616542078,"sunset":1616585719 ,"temp":{"day":303.09,"min":297.35,"max":304.92,"night":298.34,"eve":299.46,"morn":297.35},"feels_like" :{"day":307.61,"night":303.41,"eve":303.92,"morn":301.36},"pressure":1008,"humidity":71,"dew_point":297.08,"wind_speed":1.94,"wind_deg":348,"天气":[{"id":501,"main":"Rain","description" :"中雨","icon":"10d"}],"clouds":94,"pop":1,"rain":14.31,"uvi":14},{"dt":1616648400,"sunrise ":1616628453,"日落":1616672106,"温度":{"天":305.73,"分钟":296.37,"最大":305.73,"夜":298.53,"前夕":299.48,"早上":296.37 },"feels_like":{"day":309.24,"night":302.82,"eve":304.03,"morn":300.08},"pressure":1008,"humidity":55," =28=]":295.37,"wind_speed":1.96,"wind_deg":49,"天气":[{"id":501,"main":"雨","描述":"中雨","icon":"10d"}],"clouds":49,"pop":1,"rain":17.92,"uvi":14}]}