Difference between revisions of "通用预报接口/v2.2"

From Caiyun Wiki
Jump to: navigation, search
(返回结构和说明)
(返回结构和说明)
Line 97: Line 97:
 
                 astro:[{date:2018-11-20,sunset:{time:19:07},sunrise:{time:08:40}},{date:2018-11-21,sunset:{time:19:07},sunrise:{time:08:41}}],
 
                 astro:[{date:2018-11-20,sunset:{time:19:07},sunrise:{time:08:40}},{date:2018-11-21,sunset:{time:19:07},sunrise:{time:08:41}}],
 
              
 
              
         minutely:{status:ok,                                                                                                  ###请移步:[http://open.caiyunapp.com/%E7%9F%AD%E4%B8%B4%E9%99%8D%E6%B0%B4%E9%A2%84%E6%8A%A5%E6%8E%A5%E5%8F%A3/v2.2 逐分钟降水短临预报接口
+
         minutely:{status:ok,                                                                                                  ###请参考:逐分钟降水短临预报接口
 
                     precipitation_2h:[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
 
                     precipitation_2h:[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
 
                     0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
 
                     0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,

Revision as of 06:50, 30 November 2018

本文版本:通用预报接口/v2.2,当前稳定版本版本:v2.5,历史版本:v2.2v2.3,和 v2.4

授权与认证

请先至彩云开放平台注册,注册后可以获得 token 。

把您的 token 拼到 API 请求的 URL 中,如

https://api.caiyunapp.com/v2/TAkhjf8d1nlSlspN/121.6544,25.1552/weather.json

其中 TAkhjf8d1nlSlspN 就是一个共用测试 token 。不要把私有token 告诉任何人!

请求样例

示例1如下

https://api.caiyunapp.com/v2/TAkhjf8d1nlSlspN/121.6544,25.1552/weather.json
https://api.caiyunapp.com/v2/TAkhjf8d1nlSlspN/121.6544,25.1552/weather.jsonp?callback=MYCALLBACK
token:这里是测试 token ,即 TAkhjf8d1nlSlspN
经纬度:经度在前,纬度在后,中间用半角逗号隔开,这里是 121.6544,25.1552
返回格式:json 或者 jsonp,jsonp 需提供回调函数名

示例2如下

https://api.caiyunapp.com/v2/TAkhjf8d1nlSlspN/121.6544,25.1552/weather?lang=en_US&hourlysteps=2&daylysteps=2&getplacename=True
经纬度附近地址中英文名称 getplacename:True
语言选项 lang:默认为简体中文(zh_CN)、繁体中文(zh_TW)、美式英语(en_US)、英式英语(en_GB)
单位制选项 unit:默认为公制(metric)、科学单位体系(SI) 、英制(imperial)
时区偏移秒数 tzshift:默认为东八区,tzshift=28800;例如:印度东5.5区,tzshift=3600*5.5==19800,v2.3之后版本,返回时区信息,使用秒是为了支持像尼泊尔这样的差 5 小时 45 分钟的地区,它们有非整齐的偏移量
定制返回逐小时预报总小时数 hourlysteps:默认为120小时
定制返回逐日预报总日数 daylysteps:默认为5天
定制返回变量列表 fields:tmp,vis 默认返回所有变量,【'ast', 'rad', 'prc', 'tmp', 'wnd', 'hmd', 'cld', 'aqi', 'pm25', 'pm25w', 'sky', 'skyh', 'lfi', 'alr', 'pres', 'vis', 'dswrf'】
定制是否返回气象预警信息(中国气象局预警中心)alert:true (注意不要大写)
定制返回数据的起始时刻 begin:begin=1543072172 utc时间戳整数(可以返回最近的历史两天数据)

返回结构和说明

realtime分字段含义,请移步:实况接口/v2.2
minutely分字段含义,请移步:逐分钟降水短临预报接口/v2.2
hourly分字段含义,请移步:逐小时预报接口/v2.2
daily分字段含义,请移步:逐日预报接口/v2.2
alert分字段含义:
{   status:ok,
    api_version:v2.2,
    api_status:active,
    unit:metric,
    lang:en_US,
    result:{
        forecast_keypoint:cloudy, clear weather after 23 this midnight,
        primary:0,
        realtime:{status:ok,                                                                      ###请移步实况接口/v2.2
                    temperature:-1.21,
                    pres:56320.24,
                    humidity:0.09,
                    wind:{direction:284.91,speed:30.12}},
                    precipitation:{local:{status:ok,intensity:0.0,datasource:gfs}},
                    cloudrate:0.3,
                    dswrf:677.9,
                    visibility:24.1,
                    
                    skycon:PARTLY_CLOUDY_DAY,
                    ultraviolet:{index:5.0,desc:Moderat},
                    comfort:{index:11,desc:Icy wind cold},
                    
                    pm25:3,
                    pm10:10.0,
                    o3:97.0,
                    no2:2.0,
                    so2:7.0,
                    co:0.4,
                    aqi:10,
        
        hourly:{status:ok,
                    description:cloudy, clear weather after 23 this midnight,
                    temperature:[{value:-1.21,datetime:2018-11-20 16:00},{value:-0.51,datetime:2018-11-20 17:00}]},
                    pres:[{value:56320.2411405722,datetime:2018-11-20 16:00},{value:56309.4272949293,datetime:2018-11-20 17:00}],
                    humidity:[{value:0.09,datetime:2018-11-20 16:00},{value:0.11,datetime:2018-11-20 17:00}],
                    wind:[{direction:284.91,speed:30.12,datetime:2018-11-20 16:00},{direction:288.24,speed:32.91,datetime:2018-11-20 17:00}],
                    precipitation:[{value:0.0,datetime:2018-11-20 16:00},{value:0.0,datetime:2018-11-20 17:00}],
                    cloudrate:[{value:0.3,datetime:2018-11-20 16:00},{value:0.3,datetime:2018-11-20 17:00}],
                    dswrf:[{value:677.9121814107,datetime:2018-11-20 16:00},{value:596.25984,datetime:2018-11-20 17:00}],
                    visibility:[{value:24.1,datetime:2018-11-20 16:00},{value:24.1,datetime:2018-11-20 17:00}],

                    skycon:[{value:PARTLY_CLOUDY_DAY,datetime:2018-11-20 16:00},{value:WIND,datetime:2018-11-20 17:00}],
                    pm25:[{value:3,datetime:2018-11-20 16:00},{value:0,datetime:2018-11-20 17:00}],
                    aqi:[{value:10,datetime:2018-11-20 16:00},{value:0,datetime:2018-11-20 17:00}],

        daily:{status:ok,
            
                temperature:[{date:2018-11-20,max:1.19,avg:-4.35,min:-16.0},{date:2018-11-21,max:2.0,avg:-7.32,min:-18.0}],
                pres:[{date:2018-11-20,max:56600.24,avg:56422.06,min:56309.43},{date:2018-11-21,max:56833.63,avg:56653.05,min:56553.63}],
                humidity:[{date:2018-11-20,max:0.23,avg:0.14,min:0.09},{date:2018-11-21,max:0.15,avg:0.11,min:0.06}],
                wind:[{date:2018-11-20,max:{direction:290.25,speed:35.9},avg:{direction:278.27,speed:19.65},min:{direction:230.17,speed:4.77}},
                      {date:2018-11-21,max:{direction:276.13,speed:43.0},avg:{direction:262.47,speed:24.54},min:{direction:216.1,speed:12.48}}],
                precipitation:[{date:2018-11-20,max:0.0,avg:0.0,min:0.0},{date:2018-11-21,max:0.0,avg:0.0,min:0.0}],
                
                dswrf:[{date:2018-11-20,max:743.7,avg:321.5,min:0.0},{date:2018-11-21,max:748.3,avg:202.3,min:0.0}],
                cloudrate:[{date:2018-11-20,max:0.76,avg:0.49,min:0.0},{date:2018-11-21,max:0.15,avg:0.02,min:0.0}],
                visibility:[{date:2018-11-20,max:24.1,avg:24.1,min:24.1},{date:2018-11-21,max:24.1,avg:24.1,min:24.1}],
                
                skycon:[{date:2018-11-20,value:PARTLY_CLOUDY_DAY},{date:2018-11-21,value:CLEAR_DAY}],
                skycon_08h_20h:[{date:2018-11-20,value:CLEAR_DAY},{date:2018-11-21,value:CLEAR_DAY}]},
                skycon_20h_32h:[{date:2018-11-20,value:PARTLY_CLOUDY_NIGHT},{date:2018-11-21,value:CLEAR_NIGHT}],
                ultraviolet:[{index:5,desc:Very high,datetime:2018-11-20},{index:5,desc:Very high,datetime:2018-11-21}],
                comfort:[{index:13,desc:Dry cold,datetime:2018-11-20},{index:13,desc:Dry cold,datetime:2018-11-21}],
                carWashing:[{index:1,desc:Suitable,datetime:2018-11-20},{index:1,desc:Suitable,datetime:2018-11-21}],
                coldRisk:[{index:4,desc:Extremely prone,datetime:2018-11-20},{index:4,desc:Extremely prone,datetime:2018-11-21}],
                dressing:[{index:8,desc:Extremely cold,datetime:2018-11-20},{index:8,desc:Extremely cold,datetime:2018-11-21}],
                
                pm25:[{date:2018-11-20,max:3,avg:1.12,min:0},{date:2018-11-21,max:1,avg:0.58,min:0}],
                aqi:[{date:2018-11-20,max:10,avg:1.25,min:0},{date:2018-11-21,max:0,avg:0.0,min:0}],

                astro:[{date:2018-11-20,sunset:{time:19:07},sunrise:{time:08:40}},{date:2018-11-21,sunset:{time:19:07},sunrise:{time:08:41}}],
             
        minutely:{status:ok,                                                                                                   ###请参考逐分钟降水短临预报接口
                    precipitation_2h:[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
                    0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
                    0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
                    0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
                    0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],
                    precipitation:[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
                    0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
                    0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],
                    datasource:gfs,
                    description:No snow in the next hour},
       alert:{alert:{status:"ok"
              content:{
                    0:{ request_status: "ok",
                        source: "国家预警信息发布中心",

                        county: "无",
                        province: "江苏省",
                        regionId: "unknown"
                        city: "南京市",
                        code: "1303",
                        adcode: "320100",

                        alertId: "32010041600000_20181130104521",
                        status: "预警中",
                        title: "南京市气象台发布霾橙色预警[Ⅱ级/严重]",
                        description: "南京市气象台2018年11月30日10时41分升级霾黄色预警信号为霾橙色预警信号。目前我市已经出现中度霾,预计未来24小时内霾将持续,请注意防范。"

                        location: "江苏省南京市",
                        latlon: {
                            0: 32.060255,
                            1: 118.796877
                            }
                        pubtimestamp: 1543545921,
                        }
                    }
              }
    placename:Nyima, Nagqu, Tibet, China,
    location:[31.658613,
                87.815109]
    server_time:1542702509,
    tzshift:28800,
}