Skip to content

第三方服务

天气

Hekr Cloud 提供了天气的REST API服务,您可以借助它来为您的服务集成天气功能

1.天气实况

动态获取指定城市的实况天气:

curl -v -X GET \
    -H "Authorization: Bearer {JWT_TOKEN}" \
    -H "Accept: application/json" \
    -H "Content-Type: application/json" \
    "https://user-openapi.hekr.me/weather/now?location=beijing&language=zh-Hans&unit=c"

详细参数请参考API文档,若调用成功则 Hekr Cloud 返回:

< 200
{
    "results" : [{
    "location" : {
        "id" : "C23NB62W20TF",
        "name" : "西雅图",
        "country" : "US",
        "timezone" : "America/Los_Angeles",
        "timezone_offset" : "-07:00"
    },
    "now" : {
        "text" : "多云",                                  // 天气现象文字
        "code" : "4",                                    // 天气现象代码
        "temperature" : "14",                            // 温度,单位为c摄氏度或f华氏度
        "feels_like" : "14",                             // 体感温度,单位为c摄氏度或f华氏度
        "pressure" : "1018",                             // 气压,单位为mb百帕或in英寸
        "humidity" : "76",                               // 相对湿度,0~100,单位为百分比
        "visibility" : "16.09",                          // 能见度,单位为km公里或mi英里
        "wind_direction" : "西北",  
        "wind_direction_degree" : "340",
        "wind_speed" : "8.05",
        "wind_scale" : "2",
        "clouds" : "90",
        "dew_point" : "-12"                              // 露点温度,请参考:http://baike.baidu.com/view/118348.htm
    },
    "last_update" : "2015-09-25T22:45:00-07:00"          // 数据更新时间(该城市的本地时间)
    }]
}

2.空气质量实况

获取指定城市的AQI、PM2.5、PM10、一氧化碳、二氧化氮、臭氧等空气质量信息:

curl -v -X GET \
    -H "Authorization: Bearer {JWT_TOKEN}" \
    -H "Accept: application/json" \
    -H "Content-Type: application/json" \
    "https://user-openapi.hekr.me/air/now?location=beijing&language=zh-Hans&scope=city"

若调用成功,则 Hekr Cloud 返回:

< 200
< {
    "results": [{
            "location": {
                "id": "WX4FBXXFKE4F",
                "name": "北京",
                "country": "CN",
                "path": "北京,北京,中国",
                "timezone": "Asia/Shanghai",
                "timezone_offset": "+08:00"
            },
            "air": {
                "city": {                           //城市综合空气质量数据
                    "aqi": "40",                        //空气质量指数(AQI)是描述空气质量状况的定量指数
                    "pm25": "28",                       //PM2.5颗粒物(粒径小于等于2.5μm)1小时平均值。单位:μg/m³
                    "pm10": "33",                       //PM10颗粒物(粒径小于等于10μm)1小时平均值。单位:μg/m³
                    "so2": "2",                         //二氧化硫1小时平均值。单位:μg/m³
                    "no2": "32",                        //二氧化氮1小时平均值。单位:μg/m³
                    "co": "0.642",                      //一氧化碳1小时平均值。单位:mg/m³
                    "o3": "78",                         //臭氧1小时平均值。单位:μg/m³
                    "quality": "优",                    //空气质量类别,有“优、良、轻度污染、中度污染、重度污染、严重污染”6类
                    //数据发布时间
                    "last_update": "2015-09-23T13:00:00+08:00"
                },
                "stations": [{                      //该城市所有监测站数组"aqi": "50",
                        "pm25": "35",
                        "pm10": "0",
                        "so2": "2",
                        "no2": "39",
                        "co": "0.8",
                        "o3": "83",
                        "station": "万寿西宫",           //监测站名称
                        "latitude": "39.865927",        //监测站纬度
                        "longitude": "116.359805",      //监测站经度
                        "last_update": "2015-09-23T13:00:00+08:00"
                    },
                    {
                        ...                         //更多监测站
                    }
                ]
            },
            "last_update": "2015-09-23T22:45:48+08:00"
        }
    ]
}

红外