Skip to content

生活指数

访问限制

本部分 API 属于增值服务,仅提供给企业套餐开发者,如需采购请联系彩云商务

获取指定地点逐天的生活指数(如空调、过敏、钓鱼、紫外线等)。

请求

GET https://singer.caiyunhub.com/v3/lifeindex

查询参数

参数必填默认值取值范围说明
tokenAPI Token,该接口需企业权限,详见 认证与鉴权
longitude经度
latitude纬度
days1建议 1~15天数,超出可用天数时按可用天数返回,详见备注
fieldsall(不传返回全部指数)逗号分隔的指数类型数字枚举类型见 LifeIndexType,如 fields=1,2,3;获取所有指数用 fields=all,但是请做好指数增加的准备

请求示例

bash
curl "https://singer.caiyunhub.com/v3/lifeindex?token={token}&longitude=116.3883&latitude=39.9289&days=1&fields=1,2,3"
json
{
  "data": [
    {
      "date": "2022-09-30",
      "lifeindex": [
        { "type": 1, "level": 2, "desc": "舒适", "detail": "极少人需要开机" },
        {
          "type": 2,
          "level": 2,
          "desc": "易过敏",
          "detail": "敏感人群容易过敏"
        },
        {
          "type": 3,
          "level": 6,
          "desc": "非常利于垂钓",
          "detail": "气象条件极佳,非常利于垂钓"
        }
      ]
    },
    {
      "date": "2022-10-01",
      "lifeindex": [
        { "type": 1, "level": 1, "desc": "凉快", "detail": "不必开机" },
        {
          "type": 2,
          "level": 2,
          "desc": "易过敏",
          "detail": "敏感人群容易过敏"
        },
        {
          "type": 3,
          "level": 6,
          "desc": "非常利于垂钓",
          "detail": "气象条件极佳,非常利于垂钓"
        }
      ]
    }
  ]
}

响应字段

GetDailyLifeIndexResponse

FieldTypeDescription
dataDailyLifeIndex

DailyLifeIndex

FieldTypeDescription
datestring当地时区的日期
lifeindexLifeIndexItem指定的生活指数

LifeIndexItem

FieldTypeDescription
typeLifeIndexType生活指数类型
levelint32缺这个字段表示数据有异常
descstring短文本描述
detailstring长文本描述,可能和 desc 一样

LifeIndexType

NameNumberDescription
UNKNOWN_LIFEINDEX0
AirConditionerIndex1空调指数
AllergyIndex2过敏指数
AnglingIndex3钓鱼指数
AQIIndex4空气污染扩散条件指数
BoatingIndex5划船指数
CarWashingIndex6洗车指数
ColdRiskIndex7感冒指数
ComfortIndex8舒适度指数
DatingIndex9约会指数
DressingIndex10穿衣指数
DrinkingIndex11啤酒指数
DryingIndex12晾晒指数
HairdressingIndex13美发指数
HeatstrokeIndex14中暑指数
KiteIndex15放风筝指数
MakeUpIndex16化妆指数
MoodIndex17心情指数
MorningExerciseIndex18晨练指数
NightLifeIndex19夜生活指数
RainGearIndex20雨具指数
RoadConditionIndex21路况指数
ShoppingIndex22逛街指数
SportIndex23运动指数
TrafficIndex24交通指数
TravelIndex25旅游指数
UltravioletIndex26紫外线指数/防晒指数
WashClothesIndex27洗衣指数
WindColdIndex28风寒指数
StreetStallIndex30摆摊指数
TakeoutIndex31送外卖指数
CyclingIndex32骑行指数
HotPotIndex33火锅指数
MoldIndex35霉变指数
StargazingIndex36观星指数

备注

  • days <= 0 时按 1 处理;days > 15 不报错,实际返回 min(days, 数据可用天数),数据可用天数通常为 15 天。
  • fields 为逗号分隔的指数类型数字,传非法值时返回 400 错误。
  • level 字段缺失表示该指数数据异常。
  • detail 为长文本描述,可能与 desc 相同。

错误

fields 含非法指数类型等参数错误返回 HTTP 400;更多错误说明见 错误信息