indices

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

README

天气指数信息

天气生活指数是一种根据多种气象要素而计算出的指数,使用不同类型的指数可以直观的了解天气对人类活动的影响。

支持的国家或地区

天气指数并非适用于所有国家或地区,目前对于中国(包括港澳台地区),所有天气指数均可用。对于其他国家或地区,可使用运动指数、洗车指数、穿衣指数、紫外线指数和钓鱼指数。

天气指数类型

**注意:**当选择全部天气指数时,不能再选择其他指数。

天气指数类型 API类型值 iOS SDK类型常量 Android SDK类型常量
全部天气指数 0 INDICES_TYPE_all ALL
运动指数 1 INDICES_TYPE_spt SPT
洗车指数 2 INDICES_TYPE_cw CW
穿衣指数 3 INDICES_TYPE_drsg DRSG
钓鱼指数 4 INDICES_TYPE_fis FIS
紫外线指数 5 INDICES_TYPE_uv UV
旅游指数 6 INDICES_TYPE_tra TRA
花粉过敏指数 7 INDICES_TYPE_ag AG
舒适度指数 8 INDICES_TYPE_comf COMF
感冒指数 9 INDICES_TYPE_flu FLU
空气污染扩散条件指数 10 INDICES_TYPE_ap AP
空调开启指数 11 INDICES_TYPE_ac AC
太阳镜指数 12 INDICES_TYPE_gl GL
化妆指数 13 INDICES_TYPE_mu MU
晾晒指数 14 INDICES_TYPE_dc DC
交通指数 15 INDICES_TYPE_ptfc PTFC
防晒指数 16 INDICES_TYPE_spi SPI

天气指数等级

**注意:**生活指数等级有可能会进行调整。

天气指数类型 级别名称(对应等级数值)
运动指数 适宜(1)、较适宜(2)、较不宜(3)
洗车指数 适宜(1)、较适宜(2)、较不宜(3)、不宜(4)
穿衣指数 寒冷(1)、冷(2)、较冷(3)、较舒适(4)、舒适(5)、热(6)、炎热(7)
钓鱼指数 适宜(1)、较适宜(2)、不宜(3)
紫外线指数 最弱(1)、弱(2)、中等(3)、强(4)、很强(5)
旅游指数 适宜(1)、较适宜(2)、一般(3)、较不宜(4)、不适宜(5)
花粉过敏指数 极不易发(1)、不易发(2)、较易发(3)、易发(4)、极易发(5)
舒适度指数 舒适(1)、较舒适(2)、较不舒适(3)、很不舒适(4)、极不舒适(5)、不舒适(6)、非常不舒适(7)
感冒指数 少发(1)、较易发(2)、易发(3)、极易发(4)
空气污染扩散条件指数 优(1)、良(2)、中(3)、较差(4)、很差(5)
空调开启指数 长时间开启(1)、部分时间开启(2)、较少开启(3)、开启制暖空调(4)
太阳镜指数 不需要(1)、需要(2)、必要(3)、很必要(4)、非常必要(5)
化妆指数 保湿(1)、保湿防晒(2)、去油防晒(3)、防脱水防晒(4)、去油(5)、防脱水(6)、防晒(7)、滋润保湿(8)
晾晒指数 极适宜(1)、适宜(2)、基本适宜(3)、不太适宜(4)、不宜(5)、不适宜(6)
交通指数 良好(1)、较好(2)、一般(3)、较差(4)、很差(5)
防晒指数 弱(1)、较弱(2)、中等(3)、强(4)、极强(5)

Documentation

Overview

Package indices 天气指数

Index

Constants

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

Variables

View Source
var ProEndPoint *string = nil

Functions

func IndicesRequest

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

func IndicesRequestWithRequiredParam

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

IndicesRequestWithRequiredParam 天气指数预报 para 为其余参数,可以为 nil 详见 IndicesRequest

Types

type Para

type Para struct {
	Location string
	Type     string
	Lang     string
}

type Response

type Response struct {
	Code       statusCode.Code `json:"code"`       // 状态码
	UpdateTime string          `json:"updateTime"` // 当前API的最近更新时间 https://dev.qweather.com/docs/api/indices/
	FxLink     string          `json:"fxLink"`     // 当前数据的响应式页面,便于嵌入网站或应用
	Daily      []struct {
		Date     string `json:"date"`     // 预报日期
		Type     string `json:"type"`     // 生活指数类型ID
		Name     string `json:"name"`     // 生活指数类型名称
		Level    string `json:"level"`    // 生活指数预报等级
		Category string `json:"category"` // 生活指数预报级别名称
		Text     string `json:"text"`     // 生活指数预报的详细描述,**可能为空**
	} `json:"daily"`
	Refer struct {
		Sources []string `json:"sources"` // 原始数据来源,**可能为空**
		License []string `json:"license"` // 数据许可或版权声明,**可能为空**
	} `json:"refer"`
}

func Day1

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

func Day3

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

func Indices

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

Indices 天气指数预报

获取中国和全球城市天气生活指数预报数据。

中国天气生活指数:舒适度指数、洗车指数、穿衣指数、感冒指数、运动指数、旅游指数、紫外线指数、空气污染扩散条件指数、空调开启指数、过敏指数、太阳镜指数、化妆指数、晾晒指数、交通指数、钓鱼指数、防晒指数 海外天气生活指数:运动指数、洗车指数、紫外线指数、钓鱼指数

当天生活指数

https://api.qweather.com/v7/indices/1d?[请求参数] 未来3天生活指数

https://api.qweather.com/v7/indices/3d?[请求参数]

请求参数说明:

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

type(必选)

生活指数的类型ID,包括洗车指数、穿衣指数、钓鱼指数等。可以一次性获取多个类型的生活指数,多个类型用英文,分割。例如type=3,5。具体生活指数的ID和等级参考天气指数信息 https://dev.qweather.com/docs/resource/indices-info/ 各项生活指数并非适用于所有城市。

lang

多语言设置,本数据仅支持中文和英文,可选值是lang=zh 和 lang=en

函数参数说明:

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

func IndicesWithRequiredParam

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

IndicesWithRequiredParam 天气指数预报 para 为其余参数,可以为 nil 详见 Indices

Jump to

Keyboard shortcuts

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