当前位置: 首页 > Skill >

Weather Pulse

Weather Pulse

Weather Pulse

获取实时天气、3‑30 天预报、逐时预报、AQI/PM2.5、风速、湿度、紫外线指数及生活提示。由 QWeather(50k/月)和 WAQI(1k/小时)API 驱动。支持中英文城市名、经纬度坐标和 CityId。

1.3.6 2026.11.26 421
获取Skill文件查看使用说明
作 者:陆澄 许可证: 更新时间:2026.11.26
本文目录展开

weather-pulse

Weather and air quality query tool. Uses two free APIs. Both require separate registration.

Two APIs, Two Registrations Required:

  • Weather Data - QWeather: https://console.qweather.com
  • Air Quality Data - WAQI: https://aqicn.org/api/

You need both for full features. Weather-only works without WAQI token. AQI-only works without QWeather credentials.

Quick Start

1. Get API Credentials

QWeather - Free 50,000 calls/month

Register to get API Host and API Key.

  1. Open https://console.qweather.com and register or log in.
  2. Create a project with any name (e.g. "Demo").
  3. Add credentials: go to Project > Credentials > Create Credential > select API KEY.
  4. Get API Host: go to Settings in the left menu > copy the value like xxxxxxx.re.qweatherapi.com.
Config Item Required For Where to Get Example
QWEATHER_API_HOST Weather QWeather Console > Settings > API Host xxxxxxx.re.qweatherapi.com
QWEATHER_API_KEY Weather QWeather Console > Project > Credentials > API KEY xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Docs: https://dev.qweather.com/docs/start/ | Pricing: https://dev.qweather.com/docs/finance/pricing/

WAQI - Free 1,000 calls/hour

Register to get Token.

  1. Open https://aqicn.org/data-platform/token/#/
  2. Check the agreement box, fill in email and name, submit.
  3. Check your email, click the confirmation link, get the token.
Config Item Required For Where to Get Example
WAQI_API_TOKEN Air Quality WAQI email confirmation page xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Docs: https://aqicn.org/api/ | City lookup: https://aqicn.org/city/

2. Configure Credentials

Recommended: use environment variables. Do not put API keys in script files.

Storing API keys directly in code can cause leaks (e.g. accidental Git commits, shared devices). Use environment variables or a .env file.

Option A: Environment Variables (Recommended)

Only configure credentials for the features you need.

# Weather (Linux/macOS)
export QWEATHER_API_HOST="your_api_host"
export QWEATHER_API_KEY="your_api_key"

# Weather (Windows PowerShell)
$env:QWEATHER_API_HOST = "your_api_host"
$env:QWEATHER_API_KEY = "your_api_key"

# Air Quality (all platforms)
export WAQI_API_TOKEN="your_waqi_token"
# Windows PowerShell:
$env:WAQI_API_TOKEN = "your_waqi_token"

Option B: .env File

Create a .env file in the same directory as weather.py, and load it before running:

# .env file contents
QWEATHER_API_HOST=your_api_host
QWEATHER_API_KEY=your_api_key
WAQI_API_TOKEN=your_waqi_token
# Linux/macOS
set -a && source .env && set +a && python scripts/weather.py ...

# Windows PowerShell
Get-Content .env | ForEach-Object { $k,$v = $_.Split('='); Set-Item "env:$k" $v }
python scripts/weather.py ...

3. Test

# Current weather (by CityId)
python scripts/weather.py 101180301

# Air quality (by city name)
python scripts/weather.py xinxiang --endpoint aqi

Call Method

python scripts/weather.py <location> [--endpoint ENDPOINT] [--json]

If --endpoint is omitted, defaults to now (current weather).

Location Format (Auto-Parsed)

Type Format Supported Endpoints Example
CityId digits only All 101180301
English city name any All (auto-resolved to CityId) Shanghai
Chinese city name any All (auto-resolved to CityId) 上海
Coordinates lng,lat or lat,lng (auto-detected) All 113.92,35.30
geo: format "geo:lat;lng" (quotes required) AQI only "geo:35.30;113.92"
WAQI ID @number AQI only @5789
Current location here AQI only here

City name input is automatically resolved to CityId via QWeather GeoAPI. No need to look up IDs manually. Coordinate input auto-detects the order (lng,lat or lat,lng both work). The geo: format uses semicolons which require quotes in shell to avoid parsing as command separator.

Available Endpoints

Endpoint Source Free Quota Description
now QWeather 50k/mo Current weather
3d QWeather 50k/mo 3-day daily forecast
7d QWeather 50k/mo 7-day daily forecast
10d QWeather 50k/mo 10-day daily forecast
15d QWeather 50k/mo 15-day daily forecast
30d QWeather 50k/mo 30-day daily forecast
24h QWeather 50k/mo 24-hour hourly forecast
72h QWeather 50k/mo 72-hour hourly forecast
168h QWeather 50k/mo 168-hour hourly forecast
indices QWeather 50k/mo Weather lifestyle indices (19 types)
aqi WAQI 1k/hr Air quality + PM2.5/PM10 forecast

Data Reference

Current Weather now

Field Description Unit
temp Temperature °C
feelsLike Feels-like temperature °C
text / icon Weather description / icon —
windDir / windScale Wind direction / wind scale Beaufort
windSpeed Wind speed km/h
humidity Humidity %
precip Precipitation in last 1 hour mm
pressure Air pressure hPa
vis Visibility km
cloud Cloud cover %
dew Dew point temperature °C

Daily Forecast 3d/7d/10d/15d/30d

Field Description Unit
fxDate Date —
sunrise / sunset Sunrise / Sunset HH:MM
moonrise / moonset Moonrise / Moonset HH:MM
moonPhase Moon phase —
tempMax / tempMin Max temp / Min temp °C
textDay / textNight Daytime / Nighttime weather —
windDirDay / windDirNight Daytime / Nighttime wind direction —
windScaleDay / windScaleNight Daytime / Nighttime wind scale Beaufort
humidity Humidity %
precip Total precipitation for the day mm
uvIndex UV index —
pressure Air pressure hPa
vis Visibility km

Hourly Forecast 24h/72h/168h

Field Description Unit
fxTime Forecast time (ISO8601) —
temp Temperature °C
text Weather description —
windDir / windScale Wind direction / wind scale Beaufort
humidity Humidity %
pop Probability of precipitation %
precip Precipitation mm
pressure Air pressure hPa
cloud Cloud cover %
dew Dew point temperature °C

Lifestyle Indices indices

19 index types available in China: exercise, car washing, dressing, fishing, UV, travel, allergy, comfort, cold/flu, pollution diffusion, air conditioning, sunglasses, makeup, clothes drying, traffic, sunscreen, etc. Overseas locations support only 5 types: exercise, car washing, dressing, fishing, UV.

Field Description
name Index type name
category Level label
text Detailed suggestion

Air Quality aqi

Source: WAQI (aqicn.org)

Field Description Unit
aqi Air Quality Index —
dominentpol Dominant pollutant pm25/pm10/o3/no2
pm25 PM2.5 μg/m³
pm10 PM10 μg/m³
co CO mg/m³
no2 / o3 / so2 NO₂ / O₃ / SO₂ μg/m³
t / h Temperature / Humidity °C / %
p / w Air pressure / Wind speed hPa / km/h
forecast.pm25[] 7-day PM2.5 forecast avg/min/max
forecast.pm10[] 7-day PM10 forecast avg/min/max

AQI levels: Good (≤50) · Moderate (≤100) · Unhealthy for Sensitive (≤150) · Unhealthy (≤200) · Very Unhealthy (≤300) · Hazardous (>300)

Examples

# Current weather by CityId
python scripts/weather.py 101180301

# Current weather by English city name (auto-resolved)
python scripts/weather.py Shanghai

# Current weather by Chinese city name (auto-resolved)
python scripts/weather.py 上海

# 7-day forecast
python scripts/weather.py 101180301 --endpoint 7d

# 24-hour hourly forecast
python scripts/weather.py 101180301 --endpoint 24h

# 15-day forecast by coordinates (auto-detect order)
python scripts/weather.py 113.92,35.30 --endpoint 15d
python scripts/weather.py 35.30,113.92 --endpoint 15d

# Lifestyle indices
python scripts/weather.py 101180301 --endpoint indices

# Air quality by city name
python scripts/weather.py xinxiang --endpoint aqi
python scripts/weather.py 新乡 --endpoint aqi

# Air quality by coordinates
python scripts/weather.py "geo:35.30;113.92" --endpoint aqi

# Raw JSON output
python scripts/weather.py 101180301 --json

Error Codes

QWeather code WAQI status Meaning
200 ok Success
400 error Bad parameters
401 error Authentication failed (check key or token)
402 — Quota exceeded
403 — Wrong API Host

FAQ

Q: "Configuration item not set" error? A: You need to set the corresponding environment variables or use a .env file.

Q: How to find CityId? A: No need! Just enter the city name (Chinese or English), the script will automatically resolve it.

Q: What cities are supported? A: Beijing, Shanghai, Guangzhou, Shenzhen, Chengdu, Hangzhou, Nanjing, Zhengzhou, Xi'an, Chongqing, Wuhan, Kunming, Dubai, Singapore, Moscow, Rio de Janeiro, New York, Los Angeles, Chicago, London, Manchester, Edinburgh, Paris, Lyon, Marseille, Tokyo, Osaka, Kyoto, Berlin, Munich, Frankfurt, Sydney, Melbourne, Brisbane, all cities recognized by QWeather GeoAPI are supported.

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,034
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,031
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,019
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,017
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,014
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,013
Skill 文件
  • SKILL.md
    • weather-pulse
    • Quick Start
      • 1. Get API Credentials
        • QWeather - Free 50,000 calls/month
        • WAQI - Free 1,000 calls/hour
      • 2. Configure Credentials
        • Option A: Environment Variables (Recommended)
        • Option B: .env File
      • 3. Test
    • Call Method
      • Location Format (Auto-Parsed)
      • Available Endpoints
    • Data Reference
      • Current Weather now
      • Daily Forecast 3d/7d/10d/15d/30d
      • Hourly Forecast 24h/72h/168h
      • Lifestyle Indices indices
      • Air Quality aqi
    • Examples
    • Error Codes
    • FAQ
  • 项目或源文件

相关 Skill

更多
service-qa-coach service-qa-coach Review support quality for chat, email, phone, social DM, or marketplace service teams. Use when a team needs a QA scorecard, failure-mode analysis, coaching plan, calibration checklist, or service-improvement brief without live ticketing, CRM, or contact-center system access.
高中数学作业批改助手 高中数学作业批改助手 >图片识别 直接读取学生手写作答照片,识别公式、符号、步骤 🧮 自动推导 根据题目自动生成参考答案和评分细则,无需教师预设 📊 逐步给分 每个关键步骤独立评分,体现过程分 📝 结构化报告 输出含识别内容、参考答案、逐步评分、改进建议的完整报告 🗂 批量批改 支持一次性批改多道题,最终汇总得分表
Vibration Analysis Vibration Analysis 分析来自CMS趋势、RMS/峰值、频谱及SCADA报警的风机传动链(主轴、齿轮箱、发电机)振动数据。
Traditional Bone Tool Making Basics Traditional Bone Tool Making Basics Use when you need custom, durable, repairable tools like awls, needles, scrapers, harpoons, or fishing hooks made from local animal bones or antlers and comm...
音频混音工具 音频混音工具 名称:Sound Mixing Tool(标识 sound-mixing-tool) 短简介(≤60字):音乐/音效响度精确对齐 + 融合混音工作流:用 ffmpeg 两段式 loudnorm 把多组素材 LUFS 偏差压到 <0.10,再最小干预融合、导出可进引擎的独立分轨。 标签/关键词:音频混音 响度匹配 LUFS ffmpeg 游戏音频 音效设计 Wwise FMOD 分轨导出 后期处理 触发词:混音 · 响度匹配 · LUFS 对齐 · MIX 版本 · 音乐音效分轨 · 融合 · 不打架 · 不能盖住 适用场景 :游戏音频集成、影视短视频配乐、播客后期