天氣服務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"
}
}
失敗返回示例
見 接口失敗返回