OpenWeatherMap获取当天的平均温度

时间:2017-08-03 19:53:13

标签: javascript openweathermap

使用openweathermap api如何使用javascript获取某一天的平均温度。我知道我有限,只能在接下来的5天内到达。我一直在寻找并找不到办法,并且没有其他人这样做。

2 个答案:

答案 0 :(得分:0)

您可以使用api api.openweathermap.org/data/2.5/forecast?q={city name},{country code}。有关详细信息,请参阅here

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

https://openweathermap.org/forecast5

  

API调用:

     

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

     

<强>参数:

     

q城市名称和国家/地区代码除以逗号,使用ISO 3166国家/地区   码

     

API调用的示例:

     

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

答案 1 :(得分:0)

如果你使用免费模式,你可以使用API​​ this > https://api.openweathermap.org/data/2.5/onecall?lat={lat}&lon={lon}&exclude={part}&appid={API key}

对于“排除”,值为“当前”

你可以在结果“每天”中找到

如下所示,如果您使用免费模式,每天只有 7 天的数据enter image description here

{"dt":1616238000,"temp":301.64,"feels_like":305.49,"pressure":1006,"湿度":72,"dew_point":296.11,"uvi":0.17,"clouds": 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,"weather":[{"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.3 "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,"早上":300.25},"压力":1010,"湿度":54,"露点":2 94.93,"wind_speed":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, “晚上”:302.5,“夏娃”:305.49,“早晨”:300.44},“压力”:1009,“湿度”:51,“露点”:294.26,“风速”:2.17,“风度”:349,“天气":[{"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,"morn" :300.75},"压力":1009,"湿度":55,"dew_point":295.3,"wind_speed":2.31,"wind_deg":339,"weather":[{"id":500,"main": "Rain","description":"lightrain","icon":"10d"}],"clouds":88,"pop":0.48,"rain":1.85,"uvi ":13.47},{"dt":1616389200,"sunrise":1616369327,"sunset":1616412945,"temp":{"day":306.08,"min":296.6,"max":306"08,"max":306"08 :298.56,"eve":299.63,"morn":296.6},"feels_like":{"day":309.2,"night":303.14,"eve":304.4,"morn":300.19},"压力": 1010,"湿度":52,"dew_point":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.67 ,"feels_like":{"day":310.15,"night":303.02,"eve":304.13,"morn":300.55},"压力":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":297.35,"max":304.92,"night":298.34,"eve":299.46,"morn":297.35},"fe els_like":{"day":307.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,"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,"湿度":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}]}