Skip to content

BytePower Weather

P.S. BytePower Weather 由旧服务 ACB toolbox 中迁移而来,通过提供位置信息(经纬度)来获取该位置的天气信息。迁移后放置在 bytepower station 中,由 bytepower server 转发该服务。

weather conditions

英文地区(locale = en)

目前使用 OpenWeatherMap,天气现象摘自OpenWeatherMap Doc

简体中文地区(locale=zh-Hans)

目前使用心知天气,天气现象摘自心知文档

condition
晴(国内城市白天晴)
晴(国内城市夜晚晴)
晴(国外城市白天晴)
晴(国外城市夜晚晴)
多云
晴间多云
大部多云
阵雨
雷阵雨
雷阵雨伴有冰雹
小雨
中雨
大雨
暴雨
大暴雨
特大暴雨
冻雨
雨夹雪
阵雪
小雪
中雪
大雪
暴雪
浮尘
扬沙
沙尘暴
强沙尘暴
大风
飓风
热带风暴
龙卷风
未知

缓存

关于缓存设计,这里每段缓存数据的索引(key)使用的是geohash 算法,精度选择为 5(0 ~ 12 可供选择),位置偏差在 4.89km x 4.89km。 也就是说,每个 23.9121km^2^会缓存相同的天气信息,目前设置的缓存过期时间为 1hr。

缓存容量占用:以使用 owm(open weather map)为前提,每条缓存的内存占用约为 6KB,以中国面积来计算,最多可能产生 401,344 个地区块,最多会占用~ 2.4GB(在全中国每个地区块在同 1hr 内都调用了 bp 的天气服务情况下)。

接入中国本地化服务后的每地区块缓存大小,与之前计算有差异,因之前未汉化,预估一个地区块缓存为~ 6kB,现在是~ 12kB。 优化:使用 zlib 进行简单的压缩。

bp 天气服务统一输出格式

所有字段除非特殊说明,皆为字符串

输出格式:

jsonc
{
    "weather":{
        "location":{
            "country":"",
            "coordinates":"",
            "name":"",
            "detail":"",
            "tz_long":""
        },
        "observation":{
            "weather":"",
            "code":"",
            "temperature_fahrenheit":"",
            "temperature_celsius":"",
            "feelslike_fahrenheit":"",
            "feelslike_celsius":"",
            "wind_direction":"",
            "wind_kph":"",
            "wind_mph":"",
            "wind_scale":"",
            "visibility_km":"",
            "visibility_mi":"",
            "relative_humidity":"",
            "local_epoch":"",
            "observation_epoch":""
        },
        "sun_phase":{
            "sunrise":{
                "hour":"",
                "minute":""
            },
            "sunset":{
                "hour":"",
                "minute":""
            }
        },
        "daily_forecast":[
            {
                "date":{
                    "day":"",
                    "month":"",
                    "year":"",
                    "weekday":""
                },
                "high":{
                    "fahrenheit":"",
                    "celsius":""
                },
                "low":{
                    "fahrenheit":"",
                    "celsius":""
                },
                "pop":"",
                "rain_fall":"",
                "day_condition":"",
                "day_code":"",
                "night_condition":"",
                "night_code":"",
                "wind_kph":"",
                "wind_mph":"",
                "wind_direction":"",
                "wind_scale":"",
                "relative_humidity":""
            },...
        ],
        "hourly_forecast":[
            {
                "forecast_time":{
                    "year":"",
                    "month":"",
                    "day":"",
                    "weekday":"",
                    "hour":"",
                    "minute":"",
                    "second":""
                },
                "temperature":{
                    "fahrenheit":"",
                    "celsius":""
                },
                "pop":"",
                "weather":"",
                "code":"",
                "relative_humidity":"",
                "wind_kph":"",
                "wind_mph":"",
                "wind_direction":"",
                "wind_scale":""
            },...
        ],
        "history_24h": [
            {
                "code": "",
                "feelslike_celsius": {
                  "celsius": "",
                  "fahrenheit": ""
                },
                "pressure": "",
                "relative_humidity": "",
                "temperature": {
                  "celsius": "",
                  "fahrenheit": ""
                },
                "timestamp": {
                  "day": "",
                  "hour": "",
                  "month": "",
                  "year": ""
                },
                "weather": ""
            },...
        ],
        "air_quality":{
            "quality_summary":"",
            "air_quality_index":"",
            "pm2.5":"",
            "pm10":"",
            "so2":"",
            "no2":"",
            "co":"",
            "o3":""
        },
        "life_suggestion":{
            "dressing":{
                "brief":"",
                "detail":""
            },
            "ultra_violet":{
                "brief":"",
                "detail":""
            },
            "sport":{
                "brief":"",
                "detail":""
            },
            "air_pollution":{
                "brief":"",
                "detail":""
            },
            "makeup":{
                "brief":"",
                "detail":""
            },
            "flu":{
                "brief":"",
                "detail":""
            },
            "car_washing":{
                "brief":"",
                "detail":""
            },
            "fishing":{
                "brief":"",
                "detail":""
            }
        },
        "service_provider":{
            "name":"",
            "url":""
        }
    }
}

具体说明: location(地区信息)

字段含义说明
country国家名称
coordinates坐标(经纬度)格式为以空格分隔的经度纬度字符串
name所在地名字
detail详细位置locale=en 此字段没有值
tz_long时区

sun_phase(日相)

locale zh-Hans 这段信息不可用

字段含义说明
sunrise日出时间下层有 hour(小时),minute(分钟)两个字段
sunset日落时间下层有 hour(小时),minute(分钟)两个字段

observation(当前观测信息)

字段含义说明
weather天气情况概述
code天气情况代码随 service provider 的不同而不同,需要接入方自行理解
temperature_fahrenheit华氏温度
temperature_celsius摄氏温度
feelslike_fahrenheit体感温度 华氏
feelslike_celsius体感温度 摄氏
wind_direction风向
wind_kph风速(公里每小时)
wind_mph风速(英里每小时)
wind_scale风级locale en 此字段没有值
visibility_km能见度(公里)
visibility_mi能见度(英里)
relative_humidity相对湿度 (0-100)
local_epoch本地时间Unix 时间戳 精确度秒级别
observation_epoch观测时间Unix 时间戳 精确度秒级别

daily_forecast(逐日预报)

locale en 与 locale zh-Hans 均提供 10 日预报

字段含义说明
date日期下层有 year(年),month(月),day(日),weekday(星期)四个字段
high最高温度下层有 fahrenheit(华氏温度),celsius(摄氏温度)两个字段
low最低温度下层有 fahrenheit(华氏温度),celsius(摄氏温度)两个字段
pop降雨概率 (0-1 的小数)
rain_fall降雨量 (单位为 mm)locale en 此字段没有值
day_condition日间天气
day_code日间天气代码随 service provider 的不同而不同,需要接入方自行理解
night_condition夜间天气
night_code夜间天气代码随 service provider 的不同而不同,需要接入方自行理解
wind_kph风速(公里每小时)locale en 此字段没有值
wind_mph风速(英里每小时)locale en 此字段没有值
wind_direction风向locale en 此字段没有值
wind_scale风级locale en 此字段没有值
relative_humidity相对湿度 (0-100)locale en 此字段没有值

hourly_forecast(逐小时预报)

locale en 提供 36 小时预报 locale zh-Hans 提供 23 小时预报(由于第三方服务问题,该服务提供的 24 小时播报是从当前小时开始记 24 小时,而非下一小时开始记 24 小时,因此目前只能提供 23 小时预报)

字段含义说明
forecast_time预报时间下层有 year(年),month(月),day(日),weekday(星期),hour(小时),minute(分钟),second(秒)七个字段
temperature温度下层有 fahrenheit(华氏温度),celsius(摄氏温度)两个字段
pop降雨概率locale zh-Hans 此字段没有值
weather天气情况概述
code天气情况代码随 service provider 的不同而不同,需要接入方自行理解
relative_humidity相对湿度(0-100)
wind_kph风速(公里每小时)locale en 此字段没有值
wind_mph风速(英里每小时)locale en 此字段没有值
wind_direction风向locale en 此字段没有值
wind_scale风级locale en 此字段没有值

air_quality

locale en 这段信息不可用

字段含义说明
quality_summary空气质量类别有“优、良、轻度污染、中度污染、重度污染、严重污染”6 类
air_quality_index空气质量指数
pm2.5PM2.5 颗粒物(粒径小于等于 2.5μm)1 小时平均值。单位:μg/m³
pm10PM10 颗粒物(粒径小于等于 10μm)1 小时平均值。单位:μg/m³
so2二氧化硫 1 小时平均值。单位:μg/m³
no2二氧化氮 1 小时平均值。单位:μg/m³
co一氧化碳 1 小时平均值。单位:mg/m³
o3臭氧 1 小时平均值。单位:μg/m³

life_suggestion

locale en 这段信息不可用

字段含义说明
dressing穿衣
ultra_violet紫外线
sport运动
air_pollution空气污染
makeup化妆
flu感冒
car_washing洗车
fishing钓鱼

service_provider

目前在使用的两个 provider 分别是: seniverse(心知天气) -- https://www.seniverse.com open weather map -- https://openweathermap.org/

字段含义说明
name服务提供方的名称
url服务提供方的官方网址

接口

weather(天气)服务目前分两个费用档位,一个是 standard(标准)档位,一个是 economical(经济)档位,两者的主要差别在于缓存时间的长短,缓存时间越短,请求第三方服务的次数就会越多,产生的费用也就越多。

且目前,economical 档位仅支持 ip 的请求方式,standard 档位仅支持经纬度的请求方式。

standard 档位接口前缀:

  • client to server {bp_server}/bp/weather/std
  • server to server {bp_server}/bp/server/user/{user_id}/weather/std

economical 档位接口前缀:

  • client to server {bp_server}/bp/weather/eco
  • server to server {bp_server}/bp/server/user/{user_id}/weather/eco

1. (GET) 获取天气信息

client to server: {client_to_server 前缀}/report

Required Headers
X-BytePower-Sign
X-BytePower-Session-Token
economical 档位额外添加的请求头备注
X-Forwarded-For网络运营商会自动添加,客户端无需单独添加

server to server: {server_to_server 前缀}/report

Required Headers
X-BytePower-Auth-Token
economical 档位额外添加的请求头备注
X-Forwarded-For网络运营商会自动添加,客户端无需单独添加

http 请求参数

参数含义说明示例
latitude经度standard 档位必填
longitude纬度standard 档位必填
locale语言地区选填,目前支持两种 locale:“zh-Hans”简体中文,“en”英文缺省值为"zh-Hans",即默认为中文地区

示例输入 1:

优盛大厦的经纬度:latitude:40.029389, longitude:116.411597, locale:zh-Hans

客户端请求:

{bp_server}/bp/weather/std/report?latitude=40.029389&longitude=116.411597&locale=zh-Hans

服务器请求:

{bp_server}/bp/server/user/{user_id}/weather/std/report?latitude=40.029389&longitude=116.411597&locale=zh-Hans

示例输入 2:

设备当前 ip 地址:ip:220.181.38.148

客户端请求:

{bp_server}/bp/weather/eco/report?locale=zh-Hans

服务器请求:

{bp_server}/bp/server/user/{user_id}/weather/eco/report?locale=zh-Hans

示例输出:

json
{
  "weather": {
    "air_quality": {
      "air_quality_index": "20",
      "co": "0.354",
      "no2": "5",
      "o3": "61",
      "pm10": "5",
      "pm2.5": "3",
      "quality_summary": "优",
      "so2": "2"
    },
    "daily_forecast": [
      {
        "date": {
          "day": "27",
          "month": "8",
          "weekday": "5",
          "year": "2021"
        },
        "day_code": "0",
        "day_condition": "晴",
        "high": {
          "celsius": "29",
          "fahrenheit": "84"
        },
        "low": {
          "celsius": "18",
          "fahrenheit": "64"
        },
        "night_code": "1",
        "night_condition": "晴",
        "pop": "0.33",
        "rain_fall": "1.2",
        "relative_humidity": "71",
        "wind_direction": "西南",
        "wind_kph": "8.4",
        "wind_mph": "13.4",
        "wind_scale": "2"
      },
      {
        "date": {
          "day": "28",
          "month": "8",
          "weekday": "6",
          "year": "2021"
        },
        "day_code": "0",
        "day_condition": "晴",
        "high": {
          "celsius": "29",
          "fahrenheit": "84"
        },
        "low": {
          "celsius": "19",
          "fahrenheit": "66"
        },
        "night_code": "1",
        "night_condition": "晴",
        "pop": "0.35",
        "rain_fall": "1.2",
        "relative_humidity": "80",
        "wind_direction": "北",
        "wind_kph": "3.0",
        "wind_mph": "4.8",
        "wind_scale": "1"
      },
      {
        "date": {
          "day": "29",
          "month": "8",
          "weekday": "7",
          "year": "2021"
        },
        "day_code": "4",
        "day_condition": "多云",
        "high": {
          "celsius": "28",
          "fahrenheit": "82"
        },
        "low": {
          "celsius": "20",
          "fahrenheit": "68"
        },
        "night_code": "4",
        "night_condition": "多云",
        "pop": "0.65",
        "rain_fall": "2.76",
        "relative_humidity": "86",
        "wind_direction": "南",
        "wind_kph": "3.0",
        "wind_mph": "4.8",
        "wind_scale": "1"
      },
      {
        "date": {
          "day": "30",
          "month": "8",
          "weekday": "1",
          "year": "2021"
        },
        "day_code": "4",
        "day_condition": "多云",
        "high": {
          "celsius": "28",
          "fahrenheit": "82"
        },
        "low": {
          "celsius": "21",
          "fahrenheit": "69"
        },
        "night_code": "4",
        "night_condition": "多云",
        "pop": "0.36",
        "rain_fall": "1.2",
        "relative_humidity": "88",
        "wind_direction": "南",
        "wind_kph": "8.4",
        "wind_mph": "13.4",
        "wind_scale": "2"
      },
      {
        "date": {
          "day": "31",
          "month": "8",
          "weekday": "2",
          "year": "2021"
        },
        "day_code": "9",
        "day_condition": "阴",
        "high": {
          "celsius": "26",
          "fahrenheit": "78"
        },
        "low": {
          "celsius": "19",
          "fahrenheit": "66"
        },
        "night_code": "4",
        "night_condition": "多云",
        "pop": "0.72",
        "rain_fall": "3.03",
        "relative_humidity": "96",
        "wind_direction": "东",
        "wind_kph": "3.0",
        "wind_mph": "4.8",
        "wind_scale": "1"
      },
      {
        "date": {
          "day": "1",
          "month": "9",
          "weekday": "3",
          "year": "2021"
        },
        "day_code": "0",
        "day_condition": "晴",
        "high": {
          "celsius": "29",
          "fahrenheit": "84"
        },
        "low": {
          "celsius": "20",
          "fahrenheit": "68"
        },
        "night_code": "1",
        "night_condition": "晴",
        "pop": "0.35",
        "rain_fall": "1.2",
        "relative_humidity": "82",
        "wind_direction": "西南",
        "wind_kph": "3.0",
        "wind_mph": "4.8",
        "wind_scale": "1"
      },
      {
        "date": {
          "day": "2",
          "month": "9",
          "weekday": "4",
          "year": "2021"
        },
        "day_code": "4",
        "day_condition": "多云",
        "high": {
          "celsius": "31",
          "fahrenheit": "87"
        },
        "low": {
          "celsius": "19",
          "fahrenheit": "66"
        },
        "night_code": "1",
        "night_condition": "晴",
        "pop": "0.34",
        "rain_fall": "1.2",
        "relative_humidity": "76",
        "wind_direction": "南",
        "wind_kph": "3.0",
        "wind_mph": "4.8",
        "wind_scale": "1"
      },
      {
        "date": {
          "day": "3",
          "month": "9",
          "weekday": "5",
          "year": "2021"
        },
        "day_code": "13",
        "day_condition": "小雨",
        "high": {
          "celsius": "31",
          "fahrenheit": "87"
        },
        "low": {
          "celsius": "20",
          "fahrenheit": "68"
        },
        "night_code": "13",
        "night_condition": "小雨",
        "pop": "0.35",
        "rain_fall": "1.2",
        "relative_humidity": "82",
        "wind_direction": "东",
        "wind_kph": "8.4",
        "wind_mph": "13.4",
        "wind_scale": "2"
      },
      {
        "date": {
          "day": "4",
          "month": "9",
          "weekday": "6",
          "year": "2021"
        },
        "day_code": "13",
        "day_condition": "小雨",
        "high": {
          "celsius": "26",
          "fahrenheit": "78"
        },
        "low": {
          "celsius": "19",
          "fahrenheit": "66"
        },
        "night_code": "13",
        "night_condition": "小雨",
        "pop": "0.96",
        "rain_fall": "5.7",
        "relative_humidity": "90",
        "wind_direction": "东南",
        "wind_kph": "3.0",
        "wind_mph": "4.8",
        "wind_scale": "1"
      },
      {
        "date": {
          "day": "5",
          "month": "9",
          "weekday": "7",
          "year": "2021"
        },
        "day_code": "9",
        "day_condition": "阴",
        "high": {
          "celsius": "22",
          "fahrenheit": "71"
        },
        "low": {
          "celsius": "17",
          "fahrenheit": "62"
        },
        "night_code": "13",
        "night_condition": "小雨",
        "pop": "0.37",
        "rain_fall": "1.2",
        "relative_humidity": "95",
        "wind_direction": "东",
        "wind_kph": "8.4",
        "wind_mph": "13.4",
        "wind_scale": "2"
      }
    ],
    "hourly_forecast": [
      {
        "code": "4",
        "forecast_time": {
          "day": "26",
          "hour": "13",
          "minute": "0",
          "month": "8",
          "second": "0",
          "weekday": "4",
          "year": "2021"
        },
        "pop": "",
        "relative_humidity": "42",
        "temperature": {
          "celsius": "26",
          "fahrenheit": "78"
        },
        "weather": "多云",
        "wind_direction": "西南",
        "wind_kph": "10",
        "wind_mph": "16.0",
        "wind_scale": "2"
      },
      {
        "code": "4",
        "forecast_time": {
          "day": "26",
          "hour": "14",
          "minute": "0",
          "month": "8",
          "second": "0",
          "weekday": "4",
          "year": "2021"
        },
        "pop": "",
        "relative_humidity": "47",
        "temperature": {
          "celsius": "26",
          "fahrenheit": "78"
        },
        "weather": "多云",
        "wind_direction": "东南",
        "wind_kph": "10",
        "wind_mph": "16.0",
        "wind_scale": "2"
      },
      {
        "code": "4",
        "forecast_time": {
          "day": "26",
          "hour": "15",
          "minute": "0",
          "month": "8",
          "second": "0",
          "weekday": "4",
          "year": "2021"
        },
        "pop": "",
        "relative_humidity": "50",
        "temperature": {
          "celsius": "28",
          "fahrenheit": "82"
        },
        "weather": "多云",
        "wind_direction": "西南",
        "wind_kph": "10",
        "wind_mph": "16.0",
        "wind_scale": "2"
      },
      {
        "code": "4",
        "forecast_time": {
          "day": "26",
          "hour": "16",
          "minute": "0",
          "month": "8",
          "second": "0",
          "weekday": "4",
          "year": "2021"
        },
        "pop": "",
        "relative_humidity": "57",
        "temperature": {
          "celsius": "28",
          "fahrenheit": "82"
        },
        "weather": "多云",
        "wind_direction": "西南",
        "wind_kph": "10",
        "wind_mph": "16.0",
        "wind_scale": "2"
      },
      {
        "code": "4",
        "forecast_time": {
          "day": "26",
          "hour": "17",
          "minute": "0",
          "month": "8",
          "second": "0",
          "weekday": "4",
          "year": "2021"
        },
        "pop": "",
        "relative_humidity": "62",
        "temperature": {
          "celsius": "27",
          "fahrenheit": "80"
        },
        "weather": "多云",
        "wind_direction": "南",
        "wind_kph": "10",
        "wind_mph": "16.0",
        "wind_scale": "2"
      },
      {
        "code": "4",
        "forecast_time": {
          "day": "26",
          "hour": "18",
          "minute": "0",
          "month": "8",
          "second": "0",
          "weekday": "4",
          "year": "2021"
        },
        "pop": "",
        "relative_humidity": "67",
        "temperature": {
          "celsius": "26",
          "fahrenheit": "78"
        },
        "weather": "多云",
        "wind_direction": "西南",
        "wind_kph": "10",
        "wind_mph": "16.0",
        "wind_scale": "2"
      },
      {
        "code": "1",
        "forecast_time": {
          "day": "26",
          "hour": "19",
          "minute": "0",
          "month": "8",
          "second": "0",
          "weekday": "4",
          "year": "2021"
        },
        "pop": "",
        "relative_humidity": "71",
        "temperature": {
          "celsius": "26",
          "fahrenheit": "78"
        },
        "weather": "晴",
        "wind_direction": "西南",
        "wind_kph": "10",
        "wind_mph": "16.0",
        "wind_scale": "2"
      },
      {
        "code": "1",
        "forecast_time": {
          "day": "26",
          "hour": "20",
          "minute": "0",
          "month": "8",
          "second": "0",
          "weekday": "4",
          "year": "2021"
        },
        "pop": "",
        "relative_humidity": "73",
        "temperature": {
          "celsius": "25",
          "fahrenheit": "77"
        },
        "weather": "晴",
        "wind_direction": "西南",
        "wind_kph": "10",
        "wind_mph": "16.0",
        "wind_scale": "2"
      },
      {
        "code": "1",
        "forecast_time": {
          "day": "26",
          "hour": "21",
          "minute": "0",
          "month": "8",
          "second": "0",
          "weekday": "4",
          "year": "2021"
        },
        "pop": "",
        "relative_humidity": "76",
        "temperature": {
          "celsius": "24",
          "fahrenheit": "75"
        },
        "weather": "晴",
        "wind_direction": "西南",
        "wind_kph": "10",
        "wind_mph": "16.0",
        "wind_scale": "2"
      },
      {
        "code": "1",
        "forecast_time": {
          "day": "26",
          "hour": "22",
          "minute": "0",
          "month": "8",
          "second": "0",
          "weekday": "4",
          "year": "2021"
        },
        "pop": "",
        "relative_humidity": "78",
        "temperature": {
          "celsius": "23",
          "fahrenheit": "73"
        },
        "weather": "晴",
        "wind_direction": "西",
        "wind_kph": "10",
        "wind_mph": "16.0",
        "wind_scale": "2"
      },
      {
        "code": "1",
        "forecast_time": {
          "day": "26",
          "hour": "23",
          "minute": "0",
          "month": "8",
          "second": "0",
          "weekday": "4",
          "year": "2021"
        },
        "pop": "",
        "relative_humidity": "82",
        "temperature": {
          "celsius": "22",
          "fahrenheit": "71"
        },
        "weather": "晴",
        "wind_direction": "西北",
        "wind_kph": "10",
        "wind_mph": "16.0",
        "wind_scale": "2"
      },
      {
        "code": "1",
        "forecast_time": {
          "day": "27",
          "hour": "0",
          "minute": "0",
          "month": "8",
          "second": "0",
          "weekday": "5",
          "year": "2021"
        },
        "pop": "",
        "relative_humidity": "85",
        "temperature": {
          "celsius": "21",
          "fahrenheit": "69"
        },
        "weather": "晴",
        "wind_direction": "西北",
        "wind_kph": "10",
        "wind_mph": "16.0",
        "wind_scale": "2"
      },
      {
        "code": "1",
        "forecast_time": {
          "day": "27",
          "hour": "1",
          "minute": "0",
          "month": "8",
          "second": "0",
          "weekday": "5",
          "year": "2021"
        },
        "pop": "",
        "relative_humidity": "86",
        "temperature": {
          "celsius": "20",
          "fahrenheit": "68"
        },
        "weather": "晴",
        "wind_direction": "西北",
        "wind_kph": "10",
        "wind_mph": "16.0",
        "wind_scale": "2"
      },
      {
        "code": "1",
        "forecast_time": {
          "day": "27",
          "hour": "2",
          "minute": "0",
          "month": "8",
          "second": "0",
          "weekday": "5",
          "year": "2021"
        },
        "pop": "",
        "relative_humidity": "86",
        "temperature": {
          "celsius": "19",
          "fahrenheit": "66"
        },
        "weather": "晴",
        "wind_direction": "西北",
        "wind_kph": "10",
        "wind_mph": "16.0",
        "wind_scale": "2"
      },
      {
        "code": "1",
        "forecast_time": {
          "day": "27",
          "hour": "3",
          "minute": "0",
          "month": "8",
          "second": "0",
          "weekday": "5",
          "year": "2021"
        },
        "pop": "",
        "relative_humidity": "85",
        "temperature": {
          "celsius": "19",
          "fahrenheit": "66"
        },
        "weather": "晴",
        "wind_direction": "西北",
        "wind_kph": "10",
        "wind_mph": "16.0",
        "wind_scale": "2"
      },
      {
        "code": "1",
        "forecast_time": {
          "day": "27",
          "hour": "4",
          "minute": "0",
          "month": "8",
          "second": "0",
          "weekday": "5",
          "year": "2021"
        },
        "pop": "",
        "relative_humidity": "85",
        "temperature": {
          "celsius": "18",
          "fahrenheit": "64"
        },
        "weather": "晴",
        "wind_direction": "西北",
        "wind_kph": "10",
        "wind_mph": "16.0",
        "wind_scale": "2"
      },
      {
        "code": "1",
        "forecast_time": {
          "day": "27",
          "hour": "5",
          "minute": "0",
          "month": "8",
          "second": "0",
          "weekday": "5",
          "year": "2021"
        },
        "pop": "",
        "relative_humidity": "83",
        "temperature": {
          "celsius": "18",
          "fahrenheit": "64"
        },
        "weather": "晴",
        "wind_direction": "西北",
        "wind_kph": "10",
        "wind_mph": "16.0",
        "wind_scale": "2"
      },
      {
        "code": "0",
        "forecast_time": {
          "day": "27",
          "hour": "6",
          "minute": "0",
          "month": "8",
          "second": "0",
          "weekday": "5",
          "year": "2021"
        },
        "pop": "",
        "relative_humidity": "80",
        "temperature": {
          "celsius": "18",
          "fahrenheit": "64"
        },
        "weather": "晴",
        "wind_direction": "西北",
        "wind_kph": "10",
        "wind_mph": "16.0",
        "wind_scale": "2"
      },
      {
        "code": "0",
        "forecast_time": {
          "day": "27",
          "hour": "7",
          "minute": "0",
          "month": "8",
          "second": "0",
          "weekday": "5",
          "year": "2021"
        },
        "pop": "",
        "relative_humidity": "74",
        "temperature": {
          "celsius": "19",
          "fahrenheit": "66"
        },
        "weather": "晴",
        "wind_direction": "西北",
        "wind_kph": "10",
        "wind_mph": "16.0",
        "wind_scale": "2"
      },
      {
        "code": "0",
        "forecast_time": {
          "day": "27",
          "hour": "8",
          "minute": "0",
          "month": "8",
          "second": "0",
          "weekday": "5",
          "year": "2021"
        },
        "pop": "",
        "relative_humidity": "63",
        "temperature": {
          "celsius": "22",
          "fahrenheit": "71"
        },
        "weather": "晴",
        "wind_direction": "西北",
        "wind_kph": "10",
        "wind_mph": "16.0",
        "wind_scale": "2"
      },
      {
        "code": "0",
        "forecast_time": {
          "day": "27",
          "hour": "9",
          "minute": "0",
          "month": "8",
          "second": "0",
          "weekday": "5",
          "year": "2021"
        },
        "pop": "",
        "relative_humidity": "56",
        "temperature": {
          "celsius": "22",
          "fahrenheit": "71"
        },
        "weather": "晴",
        "wind_direction": "西",
        "wind_kph": "10",
        "wind_mph": "16.0",
        "wind_scale": "2"
      },
      {
        "code": "0",
        "forecast_time": {
          "day": "27",
          "hour": "10",
          "minute": "0",
          "month": "8",
          "second": "0",
          "weekday": "5",
          "year": "2021"
        },
        "pop": "",
        "relative_humidity": "51",
        "temperature": {
          "celsius": "23",
          "fahrenheit": "73"
        },
        "weather": "晴",
        "wind_direction": "西南",
        "wind_kph": "10",
        "wind_mph": "16.0",
        "wind_scale": "2"
      },
      {
        "code": "0",
        "forecast_time": {
          "day": "27",
          "hour": "11",
          "minute": "0",
          "month": "8",
          "second": "0",
          "weekday": "5",
          "year": "2021"
        },
        "pop": "",
        "relative_humidity": "47",
        "temperature": {
          "celsius": "24",
          "fahrenheit": "75"
        },
        "weather": "晴",
        "wind_direction": "东",
        "wind_kph": "10",
        "wind_mph": "16.0",
        "wind_scale": "2"
      }
    ],
    "life_suggestion": {
      "air_pollution": {
        "brief": "中",
        "detail": "气象条件对空气污染物稀释、扩散和清除无明显影响,易感人群应适当减少室外活动时间。"
      },
      "car_washing": {
        "brief": "较适宜",
        "detail": "较适宜洗车,未来一天无雨,风力较小,擦洗一新的汽车至少能保持一天。"
      },
      "dressing": {
        "brief": "热",
        "detail": "天气热,建议着短裙、短裤、短薄外套、T恤等夏季服装。"
      },
      "fishing": {
        "brief": "适宜",
        "detail": "白天风和日丽,适宜垂钓,渺渺蓝天,悠悠白云将陪伴你度过愉快的垂钓时光。"
      },
      "flu": {
        "brief": "少发",
        "detail": "各项气象条件适宜,无明显降温过程,发生感冒机率较低。"
      },
      "makeup": {
        "brief": "去油防晒",
        "detail": "建议用蜜质SPF20面霜打底,水质无油粉底霜。"
      },
      "sport": {
        "brief": "较适宜",
        "detail": "天气较好,但考虑气温较低,推荐您进行室内运动,若户外适当增减衣物并注意防晒。"
      },
      "ultra_violet": {
        "brief": "强",
        "detail": "紫外线辐射强,建议涂擦SPF20左右、PA++的防晒护肤品。避免在10点至14点暴露于日光下。"
      }
    },
    "location": {
      "coordinates": "39.99 116.4",
      "country": "CN",
      "detail": "朝阳,北京,中国",
      "name": "朝阳",
      "tz_long": "Asia/Shanghai"
    },
    "observation": {
      "code": "4",
      "feelslike_celsius": "27",
      "feelslike_fahrenheit": "80",
      "local_epoch": "1629951137",
      "observation_epoch": "1629949163",
      "relative_humidity": "36",
      "temperature_celsius": "28",
      "temperature_fahrenheit": "82",
      "visibility_km": "14.2",
      "visibility_mi": "22.7",
      "weather": "多云",
      "wind_direction": "西北",
      "wind_kph": "11.0",
      "wind_mph": "17.6",
      "wind_scale": "2"
    },
    "service_provider": {
      "name": "seniverse",
      "url": "https://www.seniverse.com/"
    },
    "sun_phase": {
      "sunrise": {
        "hour": "",
        "minute": ""
      },
      "sunset": {
        "hour": "",
        "minute": ""
      }
    }
  }
}

2.(GET) 获取当前天气

client to server: {client_to_server 前缀}/live

Required Headers
X-BytePower-Sign
X-BytePower-Session-Token
economical 档位必需报头
X-Forwarded-For

server to server: {server_to_server 前缀}/live

Required Headers
X-BytePower-Auth-Token
economical 档位必需报头
X-Forwarded-For

http 请求参数

参数含义说明示例
latitude经度standard 档位必填
longitude纬度standard 档位必填
locale语言地区选填,目前支持两种 locale:“zh-Hans”简体中文,“en”英文缺省值为"zh-Hans",即默认为中文地区

3.(GET) 获取小时天气预报

client to server: {client_to_server 前缀}/hourly

Required Headers
X-BytePower-Sign
X-BytePower-Session-Token
economical 档位必需报头
X-Forwarded-For

server to server: {server_to_server 前缀}/hourly

Required Headers
X-BytePower-Auth-Token
economical 档位必需报头
X-Forwarded-For

http 请求参数

参数含义说明示例
latitude经度standard 档位必填
longitude纬度standard 档位必填
locale语言地区选填,目前支持两种 locale:“zh-Hans”简体中文,“en”英文缺省值为"zh-Hans",即默认为中文地区

4.(GET) 获取每日天气预报

client to server: {client_to_server 前缀}/daily

Required Headers
X-BytePower-Sign
X-BytePower-Session-Token
economical 档位必需报头
X-Forwarded-For

server to server: {server_to_server 前缀}/daily

Required Headers
X-BytePower-Auth-Token
economical 档位必需报头
X-Forwarded-For

http 请求参数

参数含义说明示例
latitude经度standard 档位必填
longitude纬度standard 档位必填
locale语言地区选填,目前支持两种 locale:“zh-Hans”简体中文,“en”英文缺省值为"zh-Hans",即默认为中文地区

5.(GET) 获取空气质量指数 (locale=en 地区暂不支持)

client to server: {client_to_server 前缀}/air

Required Headers
X-BytePower-Sign
X-BytePower-Session-Token
economical 档位必需报头
X-Forwarded-For

server to server: {server_to_server 前缀}/air

Required Headers
X-BytePower-Auth-Token
economical 档位必需报头
X-Forwarded-For

http 请求参数

参数含义说明示例
latitude经度standard 档位必填
longitude纬度standard 档位必填
locale语言地区选填,目前支持两种 locale:“zh-Hans”简体中文,“en”英文缺省值为"zh-Hans",即默认为中文地区

6.(GET) 获取生活指数 (locale=en 地区暂不支持)

client to server: {client_to_server 前缀}/suggestion

Required Headers
X-BytePower-Sign
X-BytePower-Session-Token
economical 档位必需报头
X-Forwarded-For

server to server: {server_to_server 前缀}/suggestion

Required Headers
X-BytePower-Auth-Token
economical 档位必需报头
X-Forwarded-For

http 请求参数

参数含义说明示例
latitude经度standard 档位必填
longitude纬度standard 档位必填
locale语言地区选填,目前支持两种 locale:“zh-Hans”简体中文,“en”英文缺省值为"zh-Hans",即默认为中文地区

7.(GET) 获取过去 24 小时天气信息

特殊说明:因第三方(OpenWeatherMap)数据缺失,locale=en 的 response 中没有地区(location)信息

返回的过去 24 小时逐小时天气数组由过去第 1 个小时,过去第 2 个小时,一直到过去第 24 个小时顺序排列。

client to server: {client_to_server 前缀}/history_24h

Required Headers
X-BytePower-Sign
X-BytePower-Session-Token
economical 档位必需报头
X-Forwarded-For

server to server: {server_to_server 前缀}/history_24h

Required Headers
X-BytePower-Auth-Token
economical 档位必需报头
X-Forwarded-For

http 请求参数

参数含义说明示例
latitude经度standard 档位必填
longitude纬度standard 档位必填
locale语言地区选填,目前支持两种 locale:“zh-Hans”简体中文,“en”英文缺省值为"zh-Hans",即默认为中文地区

示例输出:

jsonc
{
  "weather": {
    "history_24h": [
      {
        "code": "10d",
        "feelslike_celsius": {
          "celsius": "25",
          "fahrenheit": "77"
        },
        "pressure": "1007",
        "relative_humidity": "69",
        "temperature": {
          "celsius": "24",
          "fahrenheit": "76"
        },
        "timestamp": {
          "day": "9",
          "hour": "13",
          "month": "9",
          "year": "2021"
        },
        "weather": "Rain"
      },
      {
        "code": "10d",
        "feelslike_celsius": {
          "celsius": "25",
          "fahrenheit": "77"
        },
        "pressure": "1007",
        "relative_humidity": "69",
        "temperature": {
          "celsius": "24",
          "fahrenheit": "76"
        },
        "timestamp": {
          "day": "9",
          "hour": "12",
          "month": "9",
          "year": "2021"
        },
        "weather": "Rain"
      },
      {
        "code": "04d",
        "feelslike_celsius": {
          "celsius": "26",
          "fahrenheit": "79"
        },
        "pressure": "1007",
        "relative_humidity": "65",
        "temperature": {
          "celsius": "25",
          "fahrenheit": "78"
        },
        "timestamp": {
          "day": "9",
          "hour": "11",
          "month": "9",
          "year": "2021"
        },
        "weather": "Clouds"
      },
      {
        "code": "04d",
        "feelslike_celsius": {
          "celsius": "24",
          "fahrenheit": "75"
        },
        "pressure": "1007",
        "relative_humidity": "73",
        "temperature": {
          "celsius": "23",
          "fahrenheit": "75"
        },
        "timestamp": {
          "day": "9",
          "hour": "10",
          "month": "9",
          "year": "2021"
        },
        "weather": "Clouds"
      },
      {
        "code": "50d",
        "feelslike_celsius": {
          "celsius": "22",
          "fahrenheit": "72"
        },
        "pressure": "1006",
        "relative_humidity": "94",
        "temperature": {
          "celsius": "21",
          "fahrenheit": "71"
        },
        "timestamp": {
          "day": "9",
          "hour": "9",
          "month": "9",
          "year": "2021"
        },
        "weather": "Mist"
      },
      {
        "code": "11d",
        "feelslike_celsius": {
          "celsius": "20",
          "fahrenheit": "68"
        },
        "pressure": "1005",
        "relative_humidity": "94",
        "temperature": {
          "celsius": "19",
          "fahrenheit": "67"
        },
        "timestamp": {
          "day": "9",
          "hour": "8",
          "month": "9",
          "year": "2021"
        },
        "weather": "Thunderstorm"
      },
      {
        "code": "50d",
        "feelslike_celsius": {
          "celsius": "20",
          "fahrenheit": "68"
        },
        "pressure": "1006",
        "relative_humidity": "94",
        "temperature": {
          "celsius": "19",
          "fahrenheit": "67"
        },
        "timestamp": {
          "day": "9",
          "hour": "7",
          "month": "9",
          "year": "2021"
        },
        "weather": "Mist"
      },
      {
        "code": "11d",
        "feelslike_celsius": {
          "celsius": "21",
          "fahrenheit": "70"
        },
        "pressure": "1008",
        "relative_humidity": "88",
        "temperature": {
          "celsius": "20",
          "fahrenheit": "69"
        },
        "timestamp": {
          "day": "9",
          "hour": "6",
          "month": "9",
          "year": "2021"
        },
        "weather": "Thunderstorm"
      },
      {
        "code": "50n",
        "feelslike_celsius": {
          "celsius": "20",
          "fahrenheit": "69"
        },
        "pressure": "1006",
        "relative_humidity": "100",
        "temperature": {
          "celsius": "19",
          "fahrenheit": "67"
        },
        "timestamp": {
          "day": "9",
          "hour": "5",
          "month": "9",
          "year": "2021"
        },
        "weather": "Mist"
      },
      {
        "code": "50n",
        "feelslike_celsius": {
          "celsius": "19",
          "fahrenheit": "67"
        },
        "pressure": "1007",
        "relative_humidity": "100",
        "temperature": {
          "celsius": "18",
          "fahrenheit": "66"
        },
        "timestamp": {
          "day": "9",
          "hour": "4",
          "month": "9",
          "year": "2021"
        },
        "weather": "Mist"
      },
      {
        "code": "50n",
        "feelslike_celsius": {
          "celsius": "19",
          "fahrenheit": "67"
        },
        "pressure": "1008",
        "relative_humidity": "100",
        "temperature": {
          "celsius": "18",
          "fahrenheit": "66"
        },
        "timestamp": {
          "day": "9",
          "hour": "3",
          "month": "9",
          "year": "2021"
        },
        "weather": "Mist"
      },
      {
        "code": "50n",
        "feelslike_celsius": {
          "celsius": "19",
          "fahrenheit": "67"
        },
        "pressure": "1008",
        "relative_humidity": "100",
        "temperature": {
          "celsius": "18",
          "fahrenheit": "66"
        },
        "timestamp": {
          "day": "9",
          "hour": "2",
          "month": "9",
          "year": "2021"
        },
        "weather": "Mist"
      },
      {
        "code": "50n",
        "feelslike_celsius": {
          "celsius": "20",
          "fahrenheit": "68"
        },
        "pressure": "1008",
        "relative_humidity": "94",
        "temperature": {
          "celsius": "19",
          "fahrenheit": "67"
        },
        "timestamp": {
          "day": "9",
          "hour": "1",
          "month": "9",
          "year": "2021"
        },
        "weather": "Mist"
      },
      {
        "code": "50n",
        "feelslike_celsius": {
          "celsius": "20",
          "fahrenheit": "69"
        },
        "pressure": "1008",
        "relative_humidity": "100",
        "temperature": {
          "celsius": "19",
          "fahrenheit": "67"
        },
        "timestamp": {
          "day": "9",
          "hour": "0",
          "month": "9",
          "year": "2021"
        },
        "weather": "Mist"
      },
      {
        "code": "50n",
        "feelslike_celsius": {
          "celsius": "21",
          "fahrenheit": "70"
        },
        "pressure": "1008",
        "relative_humidity": "94",
        "temperature": {
          "celsius": "20",
          "fahrenheit": "69"
        },
        "timestamp": {
          "day": "8",
          "hour": "23",
          "month": "9",
          "year": "2021"
        },
        "weather": "Mist"
      },
      {
        "code": "02n",
        "feelslike_celsius": {
          "celsius": "22",
          "fahrenheit": "72"
        },
        "pressure": "1009",
        "relative_humidity": "94",
        "temperature": {
          "celsius": "21",
          "fahrenheit": "71"
        },
        "timestamp": {
          "day": "8",
          "hour": "22",
          "month": "9",
          "year": "2021"
        },
        "weather": "Clouds"
      },
      {
        "code": "02n",
        "feelslike_celsius": {
          "celsius": "22",
          "fahrenheit": "72"
        },
        "pressure": "1008",
        "relative_humidity": "94",
        "temperature": {
          "celsius": "21",
          "fahrenheit": "71"
        },
        "timestamp": {
          "day": "8",
          "hour": "21",
          "month": "9",
          "year": "2021"
        },
        "weather": "Clouds"
      },
      {
        "code": "10n",
        "feelslike_celsius": {
          "celsius": "23",
          "fahrenheit": "74"
        },
        "pressure": "1008",
        "relative_humidity": "88",
        "temperature": {
          "celsius": "22",
          "fahrenheit": "73"
        },
        "timestamp": {
          "day": "8",
          "hour": "20",
          "month": "9",
          "year": "2021"
        },
        "weather": "Rain"
      },
      {
        "code": "09n",
        "feelslike_celsius": {
          "celsius": "25",
          "fahrenheit": "77"
        },
        "pressure": "1007",
        "relative_humidity": "73",
        "temperature": {
          "celsius": "24",
          "fahrenheit": "76"
        },
        "timestamp": {
          "day": "8",
          "hour": "19",
          "month": "9",
          "year": "2021"
        },
        "weather": "Rain"
      },
      {
        "code": "10d",
        "feelslike_celsius": {
          "celsius": "25",
          "fahrenheit": "78"
        },
        "pressure": "1007",
        "relative_humidity": "83",
        "temperature": {
          "celsius": "24",
          "fahrenheit": "76"
        },
        "timestamp": {
          "day": "8",
          "hour": "18",
          "month": "9",
          "year": "2021"
        },
        "weather": "Rain"
      },
      {
        "code": "01d",
        "feelslike_celsius": {
          "celsius": "28",
          "fahrenheit": "82"
        },
        "pressure": "1006",
        "relative_humidity": "65",
        "temperature": {
          "celsius": "26",
          "fahrenheit": "80"
        },
        "timestamp": {
          "day": "8",
          "hour": "17",
          "month": "9",
          "year": "2021"
        },
        "weather": "Clear"
      },
      {
        "code": "01d",
        "feelslike_celsius": {
          "celsius": "26",
          "fahrenheit": "79"
        },
        "pressure": "1006",
        "relative_humidity": "78",
        "temperature": {
          "celsius": "25",
          "fahrenheit": "78"
        },
        "timestamp": {
          "day": "8",
          "hour": "16",
          "month": "9",
          "year": "2021"
        },
        "weather": "Clear"
      },
      {
        "code": "01d",
        "feelslike_celsius": {
          "celsius": "29",
          "fahrenheit": "84"
        },
        "pressure": "1006",
        "relative_humidity": "57",
        "temperature": {
          "celsius": "27",
          "fahrenheit": "82"
        },
        "timestamp": {
          "day": "8",
          "hour": "15",
          "month": "9",
          "year": "2021"
        },
        "weather": "Clear"
      },
      {
        "code": "01d",
        "feelslike_celsius": {
          "celsius": "30",
          "fahrenheit": "86"
        },
        "pressure": "1006",
        "relative_humidity": "54",
        "temperature": {
          "celsius": "28",
          "fahrenheit": "84"
        },
        "timestamp": {
          "day": "8",
          "hour": "14",
          "month": "9",
          "year": "2021"
        },
        "weather": "Clear"
      }
    ],
    "service_provider": {
      "name": "open weather map",
      "url": "https://openweathermap.org"
    }
  }
}

京ICP备19011570号-2