简体   繁体   English

OpenWeatherMap 获取当天的平均温度

[英]OpenWeatherMap get average temperature on day

Using the openweathermap api how can I get the average temperature on a certain day using javascript.使用 openweathermap api 如何使用 javascript 获取某一天的平均温度。 I know I am limited with only getting with in the next 5 days.我知道我在接下来的 5 天内只能得到限制。 I have been looking and could not find a way to do it and have seen nobody else do.我一直在寻找,但找不到办法做到这一点,也没有看到其他人这样做。

You can make use of the api api.openweathermap.org/data/2.5/forecast?q={city name},{country code} .您可以使用api.openweathermap.org/data/2.5/forecast?q={city name},{country code} Please refer here for more details.请参阅此处了解更多详情。

You can search weather forecast for 5 days with data every 3 hours by city name.您可以按城市名称每 3 小时搜索 5 天的天气预报和数据。 All weather data can be obtained in JSON and XML formats.所有天气数据都可以以 JSON 和 XML 格式获取。

https://openweathermap.org/forecast5 https://openweathermap.org/forecast5

API call: API调用:

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 q 以逗号分隔的城市名称和国家/地区代码,使用 ISO 3166 国家/地区代码

Examples of API calls: API 调用示例:

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

if you use free mode, you can use API this > https://api.openweathermap.org/data/2.5/onecall?lat={lat}&lon={lon}&exclude={part}&appid={API key}如果您使用免费模式,您可以使用 API this > https://api.openweathermap.org/data/2.5/onecall?lat={lat}&lon={lon}&exclude={part}&appid={API key}

for 'exclude' the value is 'current'对于“排除”,值为“当前”

and you can find in result 'daily'你可以在结果“每天”中找到

like below, data in daily only 7 day if you use free mode如下所示,如果您使用免费模式,每天只有 7 天的数据在此处输入图片说明

{"dt":1616238000,"temp":301.64,"feels_like":305.49,"pressure":1006,"humidity":72,"dew_point":296.11,"uvi":0.17,"clouds":97,"visibility":10000,"wind_speed":1.94,"wind_deg":25,"wind_gust":4.14,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","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},"pressure":1010,"humidity":55,"dew_point":295.34,"wind_speed":1.88,"wind_deg":2,"weather":[{"id":500,"main":"Rain","description":"light rain","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" {“dt”:1616238000,“temp”:301.64,“feels_like”:305.49,“压力”:1006,“湿度”:72,“露点”:296.11,“uvi”:0.17,“云”:97,“能见度":10000,"wind_speed":1.94,"wind_deg":25,"wind_gust":4.14,"weather":[{"id":804,"main":"Clouds","description":"阴云密布","icon":"04d"}],"pop":0.39}],"每日":[{"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," 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 ,“压力”:1010,“湿度”:54,“露点”:294.93,“风速” :2.3,"wind_deg":347,"weather":[{"id":501,"main":"Rain","description":"moderate rain","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,"morn":300.44},"pressure":1009,"humidity":51,"dew_point":294.26,"wind_speed":2.17,"wind_deg":349,"weather":[{"id":500,"main":"Rain","description":"light rain","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,"morn":300.75},"pressure":1009,"humidity":55,"dew_point":295.3,"wind_speed":2.31,"wind_deg":339,"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10d"}],"clouds":88,"pop":0.48,"rain":1.85,"uvi":13.47},{"dt":161 :2.3,"wind_deg":347,"weather":[{"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,"morn":300.44},"pressure":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,"max5",30 "night":298.4,"eve":299.56,"morn":297.1},"feels_like":{"day":308.74,"night":303.18,"eve":304.47,"morn":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":161 6389200,"sunrise":1616369327,"sunset":1616412945,"temp":{"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,"weather":[{"id":500,"main":"Rain","description":"light rain","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,"wind_speed":1.7,"wind_deg":21,"weather":[{"id":501,"main":"Rain","description":"moderate rain","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":3 6389200,"日出":1616369327,"日落":1616412945,"临时":{"day":306.08,"min":296.6,"max":306.08,"night":298.56,"eve",329早晨":296.6},"feels_like":{"day":309.2,"night":303.14,"eve":304.4,"morn":300.19},"压力":1010,"湿度":52,"露点":294.84,"wind_speed":2.07,"wind_deg":13,"weather":[{"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,"湿度":48,"dew_point":294.56,"wind_speed":1.7,"wind_deg":21 ,"weather":[{"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.3":2 ,"max":304.92,"night":298.34,"eve":299.46,"morn":297.35},"feels_like":{"day":3 07.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,"weather":[{"id":501,"main":"Rain","description":"moderate rain","icon":"10d"}],"clouds":94,"pop":1,"rain":14.31,"uvi":14},{"dt":1616648400,"sunrise":1616628453,"sunset":1616672106,"temp":{"day":305.73,"min":296.37,"max":305.73,"night":298.53,"eve":299.48,"morn":296.37},"feels_like":{"day":309.24,"night":302.82,"eve":304.03,"morn":300.08},"pressure":1008,"humidity":55,"dew_point":295.37,"wind_speed":1.96,"wind_deg":49,"weather":[{"id":501,"main":"Rain","description":"moderate rain","icon":"10d"}],"clouds":49,"pop":1,"rain":17.92,"uvi":14}]} 07.61,"night":303.41,"eve":303.92,"morn":301.36},"压力":1008,"湿度":71,"dew_point":297.08,"wind_speed":1.94,"wind_deg":348 ,"weather":[{"id":501,"main":"Rain","description":"中雨","icon":"10d"}],"clouds":94,"pop": 1,"rain":14.31,"uvi":14},{"dt":1616648400,"sunrise":1616628453,"sunset":1616672106,"temp":{"day":305.73,"min7":296. ,"max":305.73,"night":298.53,"eve":299.48,"morn":296.37},"feels_like":{"day":309.24,"night":302.82,"eve":304.03,"早晨":300.08},"压力":1008,"湿度":55,"dew_point":295.37,"wind_speed":1.96,"wind_deg":49,"weather":[{"id":501,"main ":"Rain","description":"中雨","icon":"10d"}],"clouds":49,"pop":1,"rain":17.92,"uvi":14}] }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM