Documentation
¶
Overview ¶
Package warning 预警
Index ¶
- Constants
- Variables
- func CityListRequest(para *Para, key qweather.Credential, plan qweather.Version) (*http.Request, error)
- func CityListRequestWithRequiredParam(Range string, para *Para, key qweather.Credential, plan qweather.Version) (*http.Request, error)
- func RealTimeRequest(para *Para, key qweather.Credential, plan qweather.Version) (*http.Request, error)
- func RealTimeRequestWithRequiredParam(location string, para *Para, key qweather.Credential, plan qweather.Version) (*http.Request, error)
- type CityListResponse
- type Para
- type RealTimeResponse
Constants ¶
const ( EndPoint = "https://api.qweather.com/v7/warning/" FreeEndPoint = "https://devapi.qweather.com/v7/warning/" )
Variables ¶
var ProEndPoint *string = nil
Functions ¶
func CityListRequest ¶
func CityListRequest(para *Para, key qweather.Credential, plan qweather.Version) (*http.Request, error)
CityListRequest 天气预警城市列表 获取指定国家或地区当前正在发生天气灾害预警的城市列表,根据这些城市列表再查询对应城市的天气灾害预警。
> 注意:目前天气预警城市列表仅适用于获取中国(包括港澳台)城市列表。其他国家和地区,请使用天气灾害预警。
> 提示:关于更多天气预警数据的说明,请参考实用资料-预警信息。
GET https://api.qweather.com/v7/warning/list?[请求参数]
请求参数说明:
range(必选)
选择指定的国家或地区,使用ISO 3166(https://dev.qweather.com/docs/resource/glossary/#iso-3166)格式。例如range=cn或range=hk。目前该功能仅支持中国(包括港澳台)地区的城市列表,其他国家和地区请使用请使用[天气灾害预警]单独获取。
key(必选)
用户认证key,请参考如何获取你的KEY(https://dev.qweather.com/docs/configuration/project-and-key/)。支持数字签名(https://dev.qweather.com/docs/resource/signature-auth/)方式进行认证。例如 key=123456789ABC
函数参数说明
para 为请求参数 key 为用户认证key plan 为是否是免费用户
func CityListRequestWithRequiredParam ¶
func CityListRequestWithRequiredParam(Range string, para *Para, key qweather.Credential, plan qweather.Version) (*http.Request, error)
CityListRequestWithRequiredParam 天气预警城市列表 para 为其余参数,可以为 nil 详见 CityListRequest
func RealTimeRequest ¶
func RealTimeRequest(para *Para, key qweather.Credential, plan qweather.Version) (*http.Request, error)
RealTimeRequest 实时灾害预警
GET https://api.qweather.com/v7/warning/now?[请求参数]
请求参数说明:
key(必选)
用户认证key,请参考如何获取你的KEY(https://dev.qweather.com/docs/configuration/project-and-key/)。支持数字签名(https://dev.qweather.com/docs/resource/signature-auth/)方式进行认证。例如 key=123456789ABC
location(必选)
需要查询地区的LocationID(https://dev.qweather.com/docs/resource/glossary/#locationid)或以英文逗号分隔的经度,纬度坐标(十进制,最多支持小数点后两位)(https://dev.qweather.com/docs/resource/glossary/#coordinate),LocationID可通过城市搜索服务(https://dev.qweather.com/docs/api/geoapi/)获取。例如 location=101010100 或 location=116.41,39.92
lang
多语言设置,更多语言可选值参考语言代码(https://dev.qweather.com/docs/resource/language/)。当数据不匹配你设置的语言时,将返回英文或其本地语言结果。
Types ¶
type CityListResponse ¶
type CityListResponse struct { Code statusCode.Code `json:"code"` // 状态码 UpdateTime string `json:"updateTime"` // 当前API的最近更新时间 https://dev.qweather.com/docs/resource/glossary/#update-time WarningLocList []struct { LocationId string `json:"locationId"` // 当前国家预警的LocationID } `json:"warningLocList"` Refer struct { Sources []string `json:"sources"` // 原始数据来源,**可能为空** License []string `json:"license"` // 数据许可或版权声明,**可能为空** } `json:"refer"` }
func CityList ¶
func CityList(para *Para, key qweather.Credential, plan qweather.Version, client qweather.Client) (*CityListResponse, error)
CityList 天气预警城市列表 获取指定国家或地区当前正在发生天气灾害预警的城市列表,根据这些城市列表再查询对应城市的天气灾害预警。
> 注意:目前天气预警城市列表仅适用于获取中国(包括港澳台)城市列表。其他国家和地区,请使用天气灾害预警。
> 提示:关于更多天气预警数据的说明,请参考实用资料-预警信息。
GET https://api.qweather.com/v7/warning/list?[请求参数]
请求参数说明:
range(必选)
选择指定的国家或地区,使用ISO 3166(https://dev.qweather.com/docs/resource/glossary/#iso-3166)格式。例如range=cn或range=hk。目前该功能仅支持中国(包括港澳台)地区的城市列表,其他国家和地区请使用请使用[天气灾害预警]单独获取。
key(必选)
用户认证key,请参考如何获取你的KEY(https://dev.qweather.com/docs/configuration/project-and-key/)。支持数字签名(https://dev.qweather.com/docs/resource/signature-auth/)方式进行认证。例如 key=123456789ABC
函数参数说明
para 为请求参数 key 为用户认证key plan 为是否是免费用户 client 为自定义的 Client, 若为nil, 则使用http.DefaultClient
func CityListWithRequiredParam ¶
func CityListWithRequiredParam(Range string, para *Para, key qweather.Credential, plan qweather.Version, client qweather.Client) (*CityListResponse, error)
CityListWithRequiredParam 天气预警城市列表 para 为其余参数,可以为 nil 详见 CityList
type RealTimeResponse ¶
type RealTimeResponse struct { Code statusCode.Code `json:"code"` // 状态码 UpdateTime string `json:"updateTime"` // 当前API的最近更新时间 https://dev.qweather.com/docs/resource/glossary/#update-time FxLink string `json:"fxLink"` // 当前数据的响应式页面,便于嵌入网站或应用 Warning []struct { Id string `json:"id"` // 本条预警的唯一标识,可判断本条预警是否已经存在 Sender string `json:"sender"` // 预警发布单位,**可能为空** PubTime string `json:"pubTime"` // 预警发布时间 Title string `json:"title"` // 预警信息标题 StartTime string `json:"startTime"` // 预警开始时间,**可能为空** EndTime string `json:"endTime"` // 预警结束时间 https://dev.qweather.com/docs/resource/warning-info/#expiry-time 可能为空 Status string `json:"status"` // 预警信息的发布状态 https://dev.qweather.com/docs/resource/warning-info/#status // Level string `json:"level"` 预警等级 https://dev.qweather.com/docs/resource/warning-info/#level-deprecated(已弃用),不要再使用这个字段,该字段已弃用,目前返回为空或未更新的值。请使用severity和severityColor代替 Severity string `json:"severity"` // 预警严重等级 https://dev.qweather.com/docs/resource/warning-info/#severity SeverityColor string `json:"severityColor"` // 预警严重等级颜色 https://dev.qweather.com/docs/resource/warning-info/#severity-color **可能为空** Type string `json:"type"` // 预警类型ID https://dev.qweather.com/docs/resource/warning-info/#warning-type TypeName string `json:"typeName"` // 预警类型名称 https://dev.qweather.com/docs/resource/warning-info/#warning-type Urgency string `json:"urgency"` // 预警信息的紧迫程度,可能为空 https://dev.qweather.com/docs/resource/warning-info/#urgency Certainty string `json:"certainty"` // 预警信息的确定性,可能为空 https://dev.qweather.com/docs/resource/warning-info/#certainty Text string `json:"text"` // 预警详细文字描述 Related string `json:"related"` // 与本条预警相关联的预警ID,当预警状态为cancel或update时返回。**可能为空** } `json:"warning"` Refer struct { Sources []string `json:"sources"` // 原始数据来源,**可能为空** License []string `json:"license"` // 数据许可或版权声明,**可能为空** } `json:"refer"` }
func RealTime ¶
func RealTime(para *Para, key qweather.Credential, plan qweather.Version, client qweather.Client) (*RealTimeResponse, error)
RealTime 实时灾害预警
GET https://api.qweather.com/v7/warning/now?[请求参数]
请求参数说明:
key(必选)
用户认证key,请参考如何获取你的KEY(https://dev.qweather.com/docs/configuration/project-and-key/)。支持数字签名(https://dev.qweather.com/docs/resource/signature-auth/)方式进行认证。例如 key=123456789ABC
location(必选)
需要查询地区的LocationID(https://dev.qweather.com/docs/resource/glossary/#locationid)或以英文逗号分隔的经度,纬度坐标(十进制,最多支持小数点后两位)(https://dev.qweather.com/docs/resource/glossary/#coordinate),LocationID可通过城市搜索服务(https://dev.qweather.com/docs/api/geoapi/)获取。例如 location=101010100 或 location=116.41,39.92
lang
多语言设置,更多语言可选值参考语言代码(https://dev.qweather.com/docs/resource/language/)。当数据不匹配你设置的语言时,将返回英文或其本地语言结果。
函数参数说明
para 为请求参数 key 为用户认证key plan 为是否是免费用户 client 为自定义的 Client, 若为nil, 则使用http.DefaultClient
func RealTimeWithRequiredParam ¶
func RealTimeWithRequiredParam(location string, para *Para, key qweather.Credential, plan qweather.Version, client qweather.Client) (*RealTimeResponse, error)
RealTimeWithRequiredParam 实时灾害预警 para 为其余参数,可以为 nil 详见 RealTime