Documentation ¶
Overview ¶
Package v7 包含和风天气API v7的实现
Index ¶
- Constants
- func GetSignature(publicID, key string, param map[string]string) (paramstr, signature string)
- type Credential
- type HeWeatherAPI
- func NewAirQualityClient(location, duration string) (client HeWeatherAPI, err error)
- func NewGeoCityClient(location string) (client HeWeatherAPI)
- func NewGeoPOIClient(location string, poiType string) (client HeWeatherAPI)
- func NewGeoPOIRangeClient(location string, poiType string) (client HeWeatherAPI)
- func NewGeoTopCityClient() (client HeWeatherAPI)
- func NewGridRealTimeWeatherClient(location string) (client HeWeatherAPI)
- func NewGridWeatherForecastClient(location string, duration string) (client HeWeatherAPI, err error)
- func NewHistoricalClient(location, date, historicalType string) (client HeWeatherAPI, err error)
- func NewLiveIndexClient(location, indexType, duration string) (client HeWeatherAPI, err error)
- func NewMinutelyClient(location string) (client HeWeatherAPI)
- func NewMoonClient(location, date string) (client HeWeatherAPI)
- func NewOceanCurrentsClient(location, date string) (client HeWeatherAPI)
- func NewOceanTideClient(location, date string) (client HeWeatherAPI)
- func NewRealTimeWeatherClient(location string) (client HeWeatherAPI)
- func NewSolarElevationAngleClient(location, date, timeStr, tz, alt string) (client HeWeatherAPI)
- func NewSolarRadiationClient(location, duration string) (client HeWeatherAPI)
- func NewStormForecastClient(stormID string) (client HeWeatherAPI)
- func NewStormListClient(basin, year string) (client HeWeatherAPI)
- func NewStormTrackClient(stormID string) (client HeWeatherAPI)
- func NewSunClient(location, date string) (client HeWeatherAPI)
- func NewSunandMoonClient(location, date string) (client HeWeatherAPI)deprecated
- func NewWarningClient(location string) (client HeWeatherAPI)
- func NewWarningListClient(warningRange string) (client HeWeatherAPI)
- func NewWeatherForecastClient(location string, duration string) (client HeWeatherAPI, err error)
- func NewWeatherPOIClient(location, duration string) (client HeWeatherAPI, err error)deprecated
- type NewClientErr
Constants ¶
const ( Arabic = "ar" Bengali = "bn" Czech = "cs" Dutch = "nl" English = "eb" Estonian = "et" Filipino = "fil" Finnish = "fi" French = "fr" German = "de" Greek = "el" Hebrew = "he" Hindi = "hi" Icelandic = "is" Indonesian = "id" Italian = "it" Japanese = "ja" Korean = "ko" Latin = "la" Malay = "ms" Norwegian = "nb" Polish = "pl" Portuguese = "pt" Russian = "ru" SimplifiedChinese = "zh-hans" Spanish = "es" Swedish = "sv" Thai = "th" TraditionalChinese = "zh-hant" Turkish = "tr" Vietnamese = "vi" )
和风天气支持的语言代码常量
const ( NorthAtlantic = "AL" EasternPacific = "EP" NorthWestPacific = "NP" SouthWesternPacific = "SP" NorthIndian = "NI" SouthIndian = "SI" )
台风列表查询可用的basin参数常量(需要查询的台风所在的流域)
const CNAPIAddress = "https://cn-api.qweather.com/v7"
CNAPIAddress 和风天气商业版中国节点地址,当某些API在海外访问返回401时请尝试使用此地址
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Credential ¶
Credential 和风天气凭证
func NewCredential ¶
func NewCredential(publicID, key string, isBusiness bool) (credential *Credential)
NewCredential 创建一个和风天气凭证
type HeWeatherAPI ¶
type HeWeatherAPI interface { // GetFullURL 获取完整的API链接 GetFullURL(credential *Credential) (url string) // Run 执行API Run(credential *Credential) (result string, err error) // SetAPIOptionParam 设置API可选参数 SetAPIOptionParam(config map[string]string) // SetCustomAPIAddress 设置自定义API地址 SetCustomAPIAddress(address string) // SetTimeout 设置超时时间 SetTimeout(timeout time.Duration) // contains filtered or unexported methods }
HeWeatherAPI 和风天气v7API通用接口
func NewAirQualityClient ¶
func NewAirQualityClient(location, duration string) (client HeWeatherAPI, err error)
NewAirQualityClient 创建一个空气质量查询实例。 duration仅支持 now,5d https://dev.heweather.com/docs/api/air
func NewGeoCityClient ¶ added in v0.1.1
func NewGeoCityClient(location string) (client HeWeatherAPI)
NewGeoCityClient 创建一个城市信息搜索实例。 https://dev.qweather.com/docs/api/geo/city-lookup/
func NewGeoPOIClient ¶ added in v0.1.1
func NewGeoPOIClient(location string, poiType string) (client HeWeatherAPI)
NewGeoPOIClient 创建一个POI信息搜索实例。 https://dev.qweather.com/docs/api/geo/poi-lookup/
func NewGeoPOIRangeClient ¶ added in v0.1.1
func NewGeoPOIRangeClient(location string, poiType string) (client HeWeatherAPI)
NewGeoPOIRangeClient 创建一个POI范围搜索实例。 https://dev.qweather.com/docs/api/geo/poi-range/
func NewGeoTopCityClient ¶ added in v0.1.1
func NewGeoTopCityClient() (client HeWeatherAPI)
NewGeoTopCityClient 创建一个热门城市查询实例。 https://dev.qweather.com/docs/api/geo/top-city/
func NewGridRealTimeWeatherClient ¶ added in v1.1.0
func NewGridRealTimeWeatherClient(location string) (client HeWeatherAPI)
NewGridRealTimeWeatherClient 创建一个格点实况天气查询实例。 https://dev.qweather.com/docs/api/grid-weather/grid-weather-now/
func NewGridWeatherForecastClient ¶ added in v1.1.0
func NewGridWeatherForecastClient(location string, duration string) (client HeWeatherAPI, err error)
NewGridWeatherForecastClient 创建一个格点天气预报查询实例(包括逐天与逐小时)。 你需要在 https://dev.qweather.com/docs/api/grid-weather 查询指定的Duration, 如3d,24h
func NewHistoricalClient ¶
func NewHistoricalClient(location, date, historicalType string) (client HeWeatherAPI, err error)
NewHistoricalClient 创建一个历史数据查询实例。 historicalType支持传入weather,air https://dev.heweather.com/docs/api/historical
func NewLiveIndexClient ¶
func NewLiveIndexClient(location, indexType, duration string) (client HeWeatherAPI, err error)
NewLiveIndexClient 创建一个生活指数查询实例。 https://dev.heweather.com/docs/api/indices
func NewMinutelyClient ¶
func NewMinutelyClient(location string) (client HeWeatherAPI)
NewMinutelyClient 创建一个分钟级降水查询实例。 https://dev.heweather.com/docs/api/minutely
func NewMoonClient ¶ added in v1.1.0
func NewMoonClient(location, date string) (client HeWeatherAPI)
NewMoonClient 创建一个月升月落和月相查询实例。 https://dev.qweather.com/docs/api/astronomy/moon-and-moon-phase/
func NewOceanCurrentsClient ¶ added in v1.1.0
func NewOceanCurrentsClient(location, date string) (client HeWeatherAPI)
NewOceanCurrentsClient 创建一个潮流查询实例。 https://dev.qweather.com/docs/api/ocean/currents/
func NewOceanTideClient ¶ added in v1.1.0
func NewOceanTideClient(location, date string) (client HeWeatherAPI)
NewOceanTideClient 创建一个潮汐查询实例。 https://dev.qweather.com/docs/api/ocean/tide/
func NewRealTimeWeatherClient ¶
func NewRealTimeWeatherClient(location string) (client HeWeatherAPI)
NewRealTimeWeatherClient 创建一个实况天气查询实例。 https://dev.qweather.com/docs/api/weather/weather-now/
func NewSolarElevationAngleClient ¶ added in v1.1.0
func NewSolarElevationAngleClient(location, date, timeStr, tz, alt string) (client HeWeatherAPI)
NewSolarElevationAngleClient 创建一个太阳高度查询实例。 https://dev.qweather.com/docs/api/astronomy/solar-elevation-angle/
func NewSolarRadiationClient ¶ added in v1.2.0
func NewSolarRadiationClient(location, duration string) (client HeWeatherAPI)
NewSolarRadiationClient 创建一个太阳辐射查询实例。 https://dev.qweather.com/docs/api/astronomy/solar-radiation-hourly-forecast/
func NewStormForecastClient ¶ added in v1.2.0
func NewStormForecastClient(stormID string) (client HeWeatherAPI)
NewStormForecastClient 创建一个台风预报查询实例。 https://dev.qweather.com/docs/api/tropical/storm-forecast/
func NewStormListClient ¶ added in v1.2.0
func NewStormListClient(basin, year string) (client HeWeatherAPI)
NewStormListClient 创建一个台风列表查询实例。 https://dev.qweather.com/docs/api/tropical/storm-list/
func NewStormTrackClient ¶ added in v1.2.0
func NewStormTrackClient(stormID string) (client HeWeatherAPI)
NewStormTrackClient 创建一个台风实况和路径查询实例。 https://dev.qweather.com/docs/api/tropical/storm-track/
func NewSunClient ¶ added in v1.1.0
func NewSunClient(location, date string) (client HeWeatherAPI)
NewSunClient 创建一个日出日落查询实例。 https://dev.qweather.com/docs/api/astronomy/sunrise-sunset/
func NewSunandMoonClient
deprecated
func NewSunandMoonClient(location, date string) (client HeWeatherAPI)
Deprecated: 该API已被弃用拆分, 请使用 NewSunClient 和 NewMoonClient NewSunandMoonClient 创建一个日出日落、月升月落和月相查询实例。 https://dev.heweather.com/docs/api/astronomy
func NewWarningClient ¶
func NewWarningClient(location string) (client HeWeatherAPI)
NewWarningClient 创建一个灾害预警查询实例。 https://dev.qweather.com/docs/api/warning/weather-warning/
func NewWarningListClient ¶
func NewWarningListClient(warningRange string) (client HeWeatherAPI)
NewWarningListClient 创建一个灾害预警城市列表查询实例。 当前WarningRange仅支持cn https://dev.qweather.com/docs/api/warning/weather-warning-city-list/
func NewWeatherForecastClient ¶
func NewWeatherForecastClient(location string, duration string) (client HeWeatherAPI, err error)
NewWeatherForecastClient 创建一个天气预报查询实例(包括逐天与逐小时)。 你需要在 https://dev.heweather.com/docs/api/weather 查询指定的Duration, 如3d,24h
func NewWeatherPOIClient
deprecated
func NewWeatherPOIClient(location, duration string) (client HeWeatherAPI, err error)
Deprecated: 该API已被移除 NewWeatherPOIClient 创建一个景区天气查询实例。 https://dev.heweather.com/docs/api/weather-poi
type NewClientErr ¶
type NewClientErr struct {
Reason string
}
NewClientErr 创建查询实例时返回的错误
func (*NewClientErr) Error ¶
func (e *NewClientErr) Error() string