gridWeather

package
v0.0.0-...-5ed6f2c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package gridWeather 格点天气

Index

Constants

View Source
const (
	EndPoint     = "https://api.qweather.com/v7/grid-weather/"
	FreeEndPoint = "https://devapi.qweather.com/v7/grid-weather/"
)

Variables

View Source
var Now = RealTime

Now alias for RealTime

View Source
var ProEndPoint *string = nil

Functions

func DailyRequest

func DailyRequest(para *Para, key qweather.Credential, count uint8, plan qweather.Version) (*http.Request, error)

DailyRequest 每日天气预报

每日天气预报,提供全球城市未来3-7天天气预报,包括:日出日落、月升月落、最高最低温度、天气白天和夜间状况、风力、风速、风向、相对湿度、大气压强、降水量、露点温度、紫外线强度、能见度等。

3天预报 GET https://api.qweather.com/v7/weather/3d?[请求参数]

7天预报 GET https://api.qweather.com/v7/weather/7d?[请求参数]

请求参数说明:

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

key(必选)

用户认证key,请参考如何获取你的KEY(https://dev.qweather.com/docs/configuration/project-and-key/)。支持数字签名(https://dev.qweather.com/docs/resource/signature-auth/)方式进行认证。例如 key=123456789ABC

lang

多语言设置,更多语言可选值参考语言代码(https://dev.qweather.com/docs/resource/language/)。当数据不匹配你设置的语言时,将返回英文或其本地语言结果。

unit

数据单位设置,可选值包括unit=m(公制单位,默认)和unit=i(英制单位)。更多选项和说明参考度量衡单位(https://dev.qweather.com/docs/resource/unit)。

函数参数说明

para 为请求参数
key 为用户认证key
count 为天数
plan 订阅模式, 若是免费订阅, 则将上述API Host更改为devapi.qweather.com。参考免费订阅可用的数据(https://dev.qweather.com/docs/finance/subscription/#comparison)。

func DailyRequestWithRequiredParam

func DailyRequestWithRequiredParam(location string, key qweather.Credential, count uint8, para *Para, plan qweather.Version) (*http.Request, error)

DailyRequestWithRequiredParam 每日天气预报 para 为其余参数,可以为 nil 详见 DailyRequest

func HourlyRequest

func HourlyRequest(para *Para, key qweather.Credential, count uint8, plan qweather.Version) (*http.Request, error)

HourlyRequest 逐小时天气预报

逐小时天气预报,提供全球城市未来24-168小时逐小时天气预报,包括:温度、天气状况、风力、风速、风向、相对湿度、大气压强、降水概率、露点温度、云量。

逐小时预报(未来24小时) GET https://api.qweather.com/v7/grid-weather/24h?[请求参数]

逐小时预报(未来72小时) Paid plan only only 付费订阅用户可用 GET https://api.qweather.com/v7/grid-weather/72h?[请求参数]

请求参数说明:

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

key(必选)

用户认证key,请参考如何获取你的KEY(https://dev.qweather.com/docs/configuration/project-and-key/)。支持数字签名(https://dev.qweather.com/docs/resource/signature-auth/)方式进行认证。例如 key=123456789ABC

lang

多语言设置,更多语言可选值参考语言代码(https://dev.qweather.com/docs/resource/language/)。当数据不匹配你设置的语言时,将返回英文或其本地语言结果。

unit

数据单位设置,可选值包括unit=m(公制单位,默认)和unit=i(英制单位)。更多选项和说明参考度量衡单位(https://dev.qweather.com/docs/resource/unit)。

函数参数说明

para 为请求参数
key 为用户认证key
count 为小时数
plan 订阅模式, 若是免费订阅, 则将上述API Host更改为devapi.qweather.com。参考免费订阅可用的数据(https://dev.qweather.com/docs/finance/subscription/#comparison)。

func HourlyRequestWithRequiredParam

func HourlyRequestWithRequiredParam(location string, key qweather.Credential, count uint8, para *Para, plan qweather.Version) (*http.Request, error)

HourlyRequestWithRequiredParam 逐小时天气预报 para 为其余参数,可以为 nil 详见 HourlyRequest

func RealTimeRequest

func RealTimeRequest(para *Para, key qweather.Credential, plan qweather.Version) (*http.Request, error)

RealTimeRequest 格点实时天气

GET https://api.qweather.com/v7/grid-weather/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/)。当数据不匹配你设置的语言时,将返回英文或其本地语言结果。

unit

数据单位设置,可选值包括unit=m(公制单位,默认)和unit=i(英制单位)。更多选项和说明参考度量衡单位(https://dev.qweather.com/docs/resource/unit)。

函数参数说明

para 为请求参数
key 为用户认证key
plan 订阅模式, 若是免费订阅, 则将上述API Host更改为devapi.qweather.com。参考免费订阅可用的数据(https://dev.qweather.com/docs/finance/subscription/#comparison)。

func RealTimeRequestWithRequiredParam

func RealTimeRequestWithRequiredParam(location string, para *Para, key qweather.Credential, plan qweather.Version) (*http.Request, error)

RealTimeRequestWithRequiredParam 格点实时天气 para 为其余参数,可以为 nil 详见 RealTimeRequest

Types

type DailyResponse

type DailyResponse struct {
	Code       statusCode.Code `json:"code"`       // 状态码
	UpdateTime string          `json:"updateTime"` // 当前API的最近更新时间 https://dev.qweather.com/docs/resource/glossary/#update-time
	FxLink     string          `json:"fxLink"`     // 当前数据的响应式页面,便于嵌入网站或应用
	Daily      []struct {
		FxDate         string `json:"fxDate"`         // 预报日期
		TempMax        string `json:"tempMax"`        // 预报当天最高温度
		TempMin        string `json:"tempMin"`        // 预报当天最低温度
		IconDay        string `json:"iconDay"`        // 预报白天天气状况的图标代码 https://dev.qweather.com/docs/resource/icons/  另请参考天气图标项目 https://icons.qweather.com/
		IconNight      string `json:"iconNight"`      // 预报夜间天气状况的图标代码 https://dev.qweather.com/docs/resource/icons/  另请参考天气图标项目 https://icons.qweather.com/
		TextDay        string `json:"textDay"`        // 预报白天天气状况文字描述,包括阴晴雨雪等天气状态的描述
		TextNight      string `json:"textNight"`      // 预报夜间天气状况文字描述,包括阴晴雨雪等天气状态的描述
		Wind360Day     string `json:"wind360Day"`     // 预报白天风向 https://dev.qweather.com/docs/resource/wind-info/#wind-direction 360 角度
		WindDirDay     string `json:"windDirDay"`     // 预报白天风向 https://dev.qweather.com/docs/resource/wind-info/#wind-direction
		WindScaleDay   string `json:"windScaleDay"`   // 预报白天风力等级 https://dev.qweather.com/docs/resource/wind-info/#wind-direction
		WindSpeedDay   string `json:"windSpeedDay"`   // 预报白天风速 https://dev.qweather.com/docs/resource/wind-info/#wind-speed 公里/小时
		Wind360Night   string `json:"wind360Night"`   // 预报夜间风向 https://dev.qweather.com/docs/resource/wind-info/#wind-direction 360 角度
		WindDirNight   string `json:"windDirNight"`   // 预报夜间当天风向 https://dev.qweather.com/docs/resource/wind-info/#wind-direction
		WindScaleNight string `json:"windScaleNight"` // 预报夜间风力等级 https://dev.qweather.com/docs/resource/wind-info/#wind-direction
		WindSpeedNight string `json:"windSpeedNight"` // 预报夜间风速 https://dev.qweather.com/docs/resource/wind-info/#wind-speed 公里/小时
		Humidity       string `json:"humidity"`       // 预报当天相对湿度,百分比数值
		Precip         string `json:"precip"`         // 预报当天累计降水量,默认单位:毫米
		Pressure       string `json:"pressure"`       // 预报当天大气压强,默认单位:百帕
	} `json:"daily"`
	Refer struct {
		Sources []string `json:"sources"` // 原始数据来源,**可能为空**
		License []string `json:"license"` // 数据许可或版权声明,**可能为空**
	} `json:"refer"`
}

func Daily

func Daily(para *Para, key qweather.Credential, count uint8, plan qweather.Version, client qweather.Client) (*DailyResponse, error)

Daily 每日天气预报

每日天气预报,提供全球城市未来3-7天天气预报,包括:日出日落、月升月落、最高最低温度、天气白天和夜间状况、风力、风速、风向、相对湿度、大气压强、降水量、露点温度、紫外线强度、能见度等。

3天预报 GET https://api.qweather.com/v7/grid-weather/3d?[请求参数]

7天预报 GET https://api.qweather.com/v7/grid-weather/7d?[请求参数]

请求参数说明:

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

key(必选)

用户认证key,请参考如何获取你的KEY(https://dev.qweather.com/docs/configuration/project-and-key/)。支持数字签名(https://dev.qweather.com/docs/resource/signature-auth/)方式进行认证。例如 key=123456789ABC

lang

多语言设置,更多语言可选值参考语言代码(https://dev.qweather.com/docs/resource/language/)。当数据不匹配你设置的语言时,将返回英文或其本地语言结果。

unit

数据单位设置,可选值包括unit=m(公制单位,默认)和unit=i(英制单位)。更多选项和说明参考度量衡单位(https://dev.qweather.com/docs/resource/unit)。

函数参数说明

para 为请求参数
key 为用户认证key
count 为天数
plan 订阅模式, 若是免费订阅, 则将上述API Host更改为devapi.qweather.com。参考免费订阅可用的数据(https://dev.qweather.com/docs/finance/subscription/#comparison)。
client 为自定义的 Client, 若为nil, 则使用 http.DefaultClient

func DailyWithRequiredParam

func DailyWithRequiredParam(location string, key qweather.Credential, count uint8, para *Para, plan qweather.Version, client qweather.Client) (*DailyResponse, error)

DailyWithRequiredParam 每日天气预报 para 为其余参数,可以为 nil 详见 Daily

func Day3

func Day3(para *Para, key qweather.Credential, plan qweather.Version, client qweather.Client) (*DailyResponse, error)

Day3 三日天气预报 client 为自定义的 Client, 若为nil, 则使用 http.DefaultClient

func Day7

func Day7(para *Para, key qweather.Credential, plan qweather.Version, client qweather.Client) (*DailyResponse, error)

Day7 七日天气预报 client 为自定义的 Client, 若为nil, 则使用 http.DefaultClient

type HourlyResponse

type HourlyResponse struct {
	Code       statusCode.Code `json:"code"`       // 状态码
	UpdateTime string          `json:"updateTime"` // 当前API的最近更新时间 https://dev.qweather.com/docs/resource/glossary/#update-time
	FxLink     string          `json:"fxLink"`     // 当前数据的响应式页面,便于嵌入网站或应用
	Hourly     []struct {
		FxTime    string `json:"fxTime"`    // 预报时间
		Temp      string `json:"temp"`      // 温度 默认单位:摄氏度
		Icon      string `json:"icon"`      // 天气状况的图标代码 https://dev.qweather.com/docs/resource/icons/ 另请参考天气图标项目 https://icons.qweather.com/
		Text      string `json:"text"`      // 天气状况的文字描述,包括阴晴雨雪等天气状态的描述
		Wind360   string `json:"wind360"`   // 风向 https://dev.qweather.com/docs/resource/wind-info/#wind-direction 360 角度
		WindDir   string `json:"windDir"`   // 风向 https://dev.qweather.com/docs/resource/wind-info/#wind-direction
		WindScale string `json:"windScale"` // 风力等级 https://dev.qweather.com/docs/resource/wind-info/#wind-direction
		WindSpeed string `json:"windSpeed"` // 风速 https://dev.qweather.com/docs/resource/wind-info/#wind-speed 公里/小时
		Humidity  string `json:"humidity"`  // 相对湿度 百分比
		Precip    string `json:"precip"`    // 当前小时累计降水量 默认单位:毫米
		Pressure  string `json:"pressure"`  // 大气压强 默认单位:百帕
		Cloud     string `json:"cloud"`     // 云量,百分比数值,**可能为空**
		Dew       string `json:"dew"`       // 露点温度 **可能为空**
	} `json:"hourly"`
	Refer struct {
		Sources []string `json:"sources"` // 原始数据来源,**可能为空**
		License []string `json:"license"` // 数据许可或版权声明,**可能为空**
	} `json:"refer"`
}

func Hour24

func Hour24(para *Para, key qweather.Credential, plan qweather.Version, client qweather.Client) (*HourlyResponse, error)

Hour24 24小时天气预报

func Hour72

func Hour72(para *Para, key qweather.Credential, plan qweather.Version, client qweather.Client) (*HourlyResponse, error)

Hour72 72小时天气预报 Paid plan only 付费订阅用户可用

func Hourly

func Hourly(para *Para, key qweather.Credential, count uint8, plan qweather.Version, client qweather.Client) (*HourlyResponse, error)

Hourly 逐小时天气预报

逐小时天气预报,提供全球城市未来24-168小时逐小时天气预报,包括:温度、天气状况、风力、风速、风向、相对湿度、大气压强、降水概率、露点温度、云量。

逐小时预报(未来24小时) GET https://api.qweather.com/v7/grid-weather/24h?[请求参数]

逐小时预报(未来72小时) Paid plan only 付费订阅用户可用 GET https://api.qweather.com/v7/grid-weather/72h?[请求参数]

请求参数说明:

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

key(必选)

用户认证key,请参考如何获取你的KEY(https://dev.qweather.com/docs/configuration/project-and-key/)。支持数字签名(https://dev.qweather.com/docs/resource/signature-auth/)方式进行认证。例如 key=123456789ABC

lang

多语言设置,更多语言可选值参考语言代码(https://dev.qweather.com/docs/resource/language/)。当数据不匹配你设置的语言时,将返回英文或其本地语言结果。

unit

数据单位设置,可选值包括unit=m(公制单位,默认)和unit=i(英制单位)。更多选项和说明参考度量衡单位(https://dev.qweather.com/docs/resource/unit)。

函数参数说明

para 为请求参数
key 为用户认证key
count 为小时数
plan 订阅模式, 若是免费订阅, 则将上述API Host更改为devapi.qweather.com。参考免费订阅可用的数据(https://dev.qweather.com/docs/finance/subscription/#comparison)。
client 为自定义的 Client, 若为nil, 则使用http.DefaultClient

func HourlyWithRequiredParam

func HourlyWithRequiredParam(location string, key qweather.Credential, count uint8, para *Para, plan qweather.Version, client qweather.Client) (*HourlyResponse, error)

HourlyWithRequiredParam 逐小时天气预报 para 为其余参数,可以为 nil 详见 Hourly

type Para

type Para struct {
	Location string
	Lang     string
	Unit     qweather.UnitType
}

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"`     // 当前数据的响应式页面,便于嵌入网站或应用
	Now        struct {
		ObsTime   string `json:"obsTime"`   // 数据观测时间
		Temp      string `json:"temp"`      // 温度 默认单位:摄氏度
		Icon      string `json:"icon"`      // 天气状况的图标代码 https://dev.qweather.com/docs/resource/icons/ 另请参考天气图标项目 https://icons.qweather.com/
		Text      string `json:"text"`      // 天气状况的文字描述,包括阴晴雨雪等天气状态的描述
		Wind360   string `json:"wind360"`   // 风向 https://dev.qweather.com/docs/resource/wind-info/#wind-direction 360 角度
		WindDir   string `json:"windDir"`   // 风向 https://dev.qweather.com/docs/resource/wind-info/#wind-direction
		WindScale string `json:"windScale"` // 风力等级 https://dev.qweather.com/docs/resource/wind-info/#wind-direction
		WindSpeed string `json:"windSpeed"` // 风速 https://dev.qweather.com/docs/resource/wind-info/#wind-speed 公里/小时
		Humidity  string `json:"humidity"`  // 相对湿度 百分比
		Precip    string `json:"precip"`    // 当前小时累计降水量,默认单位:毫米
		Pressure  string `json:"pressure"`  // 大气压强,默认单位:百帕
		Cloud     string `json:"cloud"`     // 云量,百分比数值。**可能为空**
		Dew       string `json:"dew"`       // 露点温度。**可能为空**
	} `json:"now"`
	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/grid-weather/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/)。当数据不匹配你设置的语言时,将返回英文或其本地语言结果。

unit

数据单位设置,可选值包括unit=m(公制单位,默认)和unit=i(英制单位)。更多选项和说明参考度量衡单位(https://dev.qweather.com/docs/resource/unit)。

函数参数说明

para 为请求参数
key 为用户认证key
plan 订阅模式, 若是免费订阅, 则将上述API Host更改为devapi.qweather.com。参考免费订阅可用的数据(https://dev.qweather.com/docs/finance/subscription/#comparison)。

func RealTimeWithRequiredParam

func RealTimeWithRequiredParam(location string, para *Para, key qweather.Credential, plan qweather.Version, client qweather.Client) (*RealTimeResponse, error)

RealTimeWithRequiredParam 格点实时天气 para 为其余参数,可以为 nil 详见 RealTime

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL