airqualityBeta

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: 6 Imported by: 0

Documentation

Overview

Package airqualityBeta 和风天气 空气质量(beta) 推荐阅读空气质量信息文档,以便了解指数类型、污染物、支持的国家等信息。 全新的实时空气质量目前处于beta阶段,标准订阅暂不收取费用。数据内容在正式发布后可能会有所不同。查看当前版本的发行公告。 https://blog.qweather.com/announce/aqi-v1-1-released/ 推荐阅读空气质量信息文档,以便了解指数类型、污染物、支持的国家等信息。 https://dev.qweather.com/docs/resource/air-info/ 全新的监测站数据目前处于beta阶段,标准订阅暂不收取费用。数据内容在正式发布后可能会有所不同。 监测站数据是实验性数据,仅供参考,可能受到各种因素的影响,我们无法确保该数据的可用性,请优先使用空气质量指数数据。 目前测试使用数字签名方式进行认证的情况下会遇到 401 认证失败的情况

Index

Constants

View Source
const (
	StandardEndPoint = "https://api.qweather.com/airquality/v1/"
	FreeEndPoint     = "https://devapi.qweather.com/airquality/v1/"
)

Variables

View Source
var ProEndPoint *string = nil
View Source
var RealTime = Now

RealTime alias for Now

Functions

func NowRequest

func NowRequest(para *NowPara, key qweather.Credential, plan qweather.Version) (*http.Request, error)

func StationRequest

func StationRequest(para *StationPara, key qweather.Credential, plan qweather.Version) (*http.Request, error)

Types

type NowAirQualityResponse

type NowAirQualityResponse struct {
	Code       statusCode.Code `json:"code"`       // 状态码
	UpdateTime string          `json:"updateTime"` // 当前API的最近更新时间 https://dev.qweather.com/docs/resource/glossary/#update-time
	Aqi        []struct {
		Code            string `json:"code"`            // 空气质量指数 Code https://dev.qweather.com/docs/resource/air-info/#supported-aqis
		Name            string `json:"name"`            // 空气质量指数的名字
		DefaultLocalAqi bool   `json:"defaultLocalAqi"` // 是否是默认/推荐的当地AQI https://dev.qweather.com/docs/resource/air-info/#default-local-aqi
		Value           int    `json:"value"`           // 空气质量指数的值 https://dev.qweather.com/docs/resource/air-info/#aqi-value
		ValueDisplay    string `json:"valueDisplay"`    // 空气质量指数的值的文本显示 https://dev.qweather.com/docs/resource/air-info/#aqi-value
		Level           string `json:"level"`           // 空气质量指数等级,可能为空
		Category        string `json:"category"`        // 空气质量指数类别,可能为空
		Color           string `json:"color"`           // 空气质量指数的颜色,RGB格式
		Health          struct {
			Effect string `json:"effect"` // 空气质量对健康的影响,可能为空 https://dev.qweather.com/docs/resource/air-info/#health-effects-and-advice
			Advice struct {
				GeneralPopulation   string `json:"generalPopulation"`   // 对一般人群的健康指导意见,可能为空
				SensitivePopulation string `json:"sensitivePopulation"` // 对敏感人群的健康指导意见,可能为空
			} `json:"advice"`
		} `json:"health"`
		PrimaryPollutant struct {
			Code     string `json:"code"`     // 首要污染物的Code,可能为空 https://dev.qweather.com/docs/resource/air-info/#primary-pollutant
			Name     string `json:"name"`     // 首要污染物的名字,可能为空
			FullName string `json:"fullName"` // 首要污染物的全称,可能为空
		} `json:"primaryPollutant,omitempty"`
	} `json:"aqi"`
	Pollutant []struct {
		Code          string `json:"code"`     // 污染物的 Code https://dev.qweather.com/docs/resource/air-info/#pollutants
		Name          string `json:"name"`     // 污染物的名字
		FullName      string `json:"fullName"` // 污染物的全称
		Concentration struct {
			Value float64 `json:"value"` // 污染物的浓度值
			Unit  string  `json:"unit"`  // 污染物的浓度值的单位
		} `json:"concentration"`
		SubIndex struct {
			Value        int    `json:"value"`        // 污染物的分指数的数值,可能为空 https://dev.qweather.com/docs/resource/air-info/#pollutant-sub-index
			ValueDisplay string `json:"valueDisplay"` // 污染物的分指数数值的显示名称
		} `json:"subIndex"`
	} `json:"pollutant"`
	Station []struct {
		Id   string `json:"id"`   // AQI相关联的监测站Location ID,可能为空
		Name string `json:"name"` // AQI相关联的监测站名称
	} `json:"station"`
	Source []string `json:"source"` // 数据来源或提供商名字以及他们的声明,必须与空气质量数据一起展示。可能为空
}

func Now

func Now(para *NowPara, key qweather.Credential, plan qweather.Version, client qweather.Client) (*NowAirQualityResponse, error)

func NowWithRequiredParam

func NowWithRequiredParam(locationID string, key qweather.Credential, para *NowPara, plan qweather.Version, client qweather.Client) (*NowAirQualityResponse, error)

func Station

func Station(para *StationPara, key qweather.Credential, plan qweather.Version, client qweather.Client) (*NowAirQualityResponse, error)

func StationWithRequiredParam

func StationWithRequiredParam(locationID string, key qweather.Credential, para *StationPara, plan qweather.Version, client qweather.Client) (*NowAirQualityResponse, error)

type NowPara

type NowPara struct {
	LocationID string
	Lang       string
	Station    bool
	Pollutant  bool
}

type StationPara

type StationPara struct {
	LocationID string
	Lang       string
}

type StationResponse

type StationResponse struct {
	Code       statusCode.Code `json:"code"`       // 状态码
	UpdateTime string          `json:"updateTime"` // 当前API的最近更新时间 https://dev.qweather.com/docs/resource/glossary/#update-time
	Pollutant  []struct {
		Code          string `json:"code"`     // 污染物的 Code https://dev.qweather.com/docs/resource/air-info/#pollutants
		Name          string `json:"name"`     // 污染物的名字
		FullName      string `json:"fullName"` // 污染物的全称
		Concentration struct {
			Value string `json:"value"` // 污染物的浓度值
			Unit  string `json:"unit"`  // 污染物的浓度值的单位
		} `json:"concentration"`
	} `json:"pollutant"`
	Source []string `json:"source"` // 数据来源或提供商名字以及他们的声明,必须与空气质量数据一起展示。可能为空
}

Jump to

Keyboard shortcuts

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