如何从 openweathermap api 获取数据和时间?
我试图从 JS 中的 openweathermap api 为我的网站获取数据 但在json文件中缺少一些参数 像日出日落日期时区等(顺便说一句,使用免费 API) 下面是api调用的json格式
{
"message": "accurate",
"cod": "200",
"count": 1,
"list": [
{
"id": 1275004,
"name": "Kolkata",
"coord": {
"lat": 22.5697,
"lon": 88.3697
},
"main": {
"temp": 28.97,
"feels_like": 28.49,
"temp_min": 28.35,
"temp_max": 28.97,
"pressure": 1009,
"humidity": 39
},
"dt": 1646658548,
"wind": {
"speed": 2.06,
"deg": 320
},
"sys": {
"country": "IN"
},
"rain": null,
"snow": null,
"clouds": {
"all": 0
},
"weather": [
{
"id": 721,
"main": "Haze",
"description": "haze",
"icon": "50n"
}
]
}
]
}
如何获取日期和时间?
I was trying to fetch datas from openweathermap api in JS for my website
but in the json file some parameters are missing
like sunrise sunset date timezone etc (btw using free api)
below is the json format of the api call
{
"message": "accurate",
"cod": "200",
"count": 1,
"list": [
{
"id": 1275004,
"name": "Kolkata",
"coord": {
"lat": 22.5697,
"lon": 88.3697
},
"main": {
"temp": 28.97,
"feels_like": 28.49,
"temp_min": 28.35,
"temp_max": 28.97,
"pressure": 1009,
"humidity": 39
},
"dt": 1646658548,
"wind": {
"speed": 2.06,
"deg": 320
},
"sys": {
"country": "IN"
},
"rain": null,
"snow": null,
"clouds": {
"all": 0
},
"weather": [
{
"id": 721,
"main": "Haze",
"description": "haze",
"icon": "50n"
}
]
}
]
}
how to get date and time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用您的 APP ID 尝试此 API
https://api.openweathermap.org/data/2.5/ Weather?q=%20Oakland&appid= //
您将从 API 获取此 JSON
- 或
https://api.openweathermap.org/data/2.5/forecast?q=%20Oakland&mode=json&units=imperial&appid= //
使用此 API 您将获得多个数据。
Try this API with your APP ID
https://api.openweathermap.org/data/2.5/weather?q=%20Oakland&appid= //
you will get this JSON from API-
or
https://api.openweathermap.org/data/2.5/forecast?q=%20Oakland&mode=json&units=imperial&appid= //
you will get multiple data using this API.