天气服务API
按国家城市获取天气
接口地址
POST /api/v1.0/invoke/open-ability/method/general-commands
请求参数
| 参数名 | 类型 | 位置 | 必填 | 说明 |
|---|---|---|---|---|
| Content-Type | String | Header | 是 | 内容类型,值为application/json |
| Accept | String | Header | 是 | 接受类型,值为application/json |
| Authorization | String | Header | 是 | Bearer认证,访问令牌 |
| command | String | Body | 是 | 命令名称 |
| id | String | Body | 是 | 命令ID |
| param | Object<param> | Body | 是 | 命令参数 |
param说明
| 参数名 | 类型 | 位置 | 必填 | 说明 |
|---|---|---|---|---|
| country | String | Body | 是 | 国家 |
| state_province | String | Body | 是 | 州/省 |
| city | String | Body | 是 | 城市 |
返回参数
| 参数名 | 类型 | 位置 | 说明 |
|---|---|---|---|
| Content-Type | String | Header | 内容类型,值为application/json |
| success | Boolean | Body | 判断请求是否成功 true:成功 false:失败 |
| timestamp | Integer | Body | 时间戳 |
| result | Object<result> | Body | 返回结果 |
result说明
| 参数名 | 类型 | 位置 | 说明 |
|---|---|---|---|
| weather | String | Body | 天气类型 sunny:晴 cloudy:阴 rainy:雨 snowy:雪 foggy:雾 |
| temperature | String | Body | 温度(℃) |
| humidity | String | Body | 湿度(%RH) |
| wind_speed | String | Body | 风速(m/s) |
| aqi | String | Body | 空气质量指数 |
请求示例
POST /api/v1.0/invoke/open-ability/method/general-commands
Content-Type: application/json
Accept: application/json
Authorization: Bearer ac45e846ca23ab42c9ae469d988ae32a9
{
"command": "get_weather_by_country_and_city",
"id": "c45e846ca23ab42c9ae469d988ae32a96",
"param": {
"country": "Brazil",
"state_province": "Bahia",
"city": "Rodelas"
}
}
成功返回示例
状态码:200
{
"success": true,
"timestamp": 1540869200562,
"result": {
"aqi": "19",
"humidity": "79",
"temperature": "21",
"weather": "sunny",
"wind_speed": "4.725265"
}
}
失败返回示例
见 接口失败返回
按经纬度获取天气
接口地址
POST /api/v1.0/invoke/open-ability/method/general-commands
请求参数
| 参数名 | 类型 | 位置 | 必填 | 说明 |
|---|---|---|---|---|
| Content-Type | String | Header | 是 | 内容类型,值为application/json |
| Accept | String | Header | 是 | 接受类型,值为application/json |
| Authorization | String | Header | 是 | Bearer认证,访问令牌 |
| command | String | Body | 是 | 命令名称 |
| id | String | Body | 是 | 命令ID |
| param | Object<param> | Body | 是 | 命令参数 |
param说明
| 参数名 | 类型 | 位置 | 必填 | 说明 |
|---|---|---|---|---|
| latitude | String | Body | 是 | 纬度 |
| longitude | String | Body | 是 | 经度 |
返回参数
| 参数名 | 类型 | 位置 | 说明 |
|---|---|---|---|
| Content-Type | String | Header | 内容类型,值为application/json |
| success | Boolean | Body | 判断请求是否成功 true:成功 false:失败 |
| timestamp | Integer | Body | 时间戳 |
| result | Object<result> | Body | 返回结果 |
result说明
| 参数名 | 类型 | 类型 | 位置 | 位置 | 说明 |
|---|---|---|---|---|---|
| weather | String | String | Body | Body | 天气类型 sunny:晴 cloudy:阴 rainy:雨 snowy:雪 foggy:雾 |
| temperature | String | String | Body | Body | 温度(℃) |
| humidity | String | String | Body | Body | 湿度(%RH) |
| wind_speed | String | Body | Body | 风速(m/s) | 风速(m/s) |
| aqi | String | Body | Body | 空气质量指数 | 空气质量指数 |
请求示例
POST /api/v1.0/invoke/open-ability/method/general-commands
Content-Type: application/json
Accept: application/json
Authorization: Bearer ac45e846ca23ab42c9ae469d988ae32a9
{
"command": "get_weather_by_longitude_and_latitude",
"id": "c45e846ca23ab42c9ae469d988ae32a96",
"param": {
"latitude": "-8.8508",
"longitude": "-38.7558"
}
}
成功返回示例
状态码:200
Content-Type: application/json
{
"success": true,
"timestamp": 1540869200562,
"result": {
"aqi": "19",
"humidity": "79",
"temperature": "21",
"weather": "sunny",
"wind_speed": "4.725265"
}
}
失败返回示例
见 接口失败返回