Source Code
kma-weather
Quick Start
# Current weather + 6-hour forecast
python3 skills/kma-weather/scripts/forecast.py brief --lat 37.5665 --lon 126.9780
# All forecasts as JSON (current + ultrashort + shortterm)
python3 skills/kma-weather/scripts/forecast.py all --lat 37.5665 --lon 126.9780 --json
# Short-term forecast (3 days)
python3 skills/kma-weather/scripts/forecast.py shortterm --lat 37.5665 --lon 126.9780 --days all
# Nationwide weather warnings/advisories (๊ธฐ์ํน๋ณด)
python3 skills/kma-weather/scripts/weather_warnings.py
# Mid-term forecast (3-10 days)
python3 skills/kma-weather/scripts/midterm.py --region ์์ธ
Setup
1. Get API Key
- Visit ๊ณต๊ณต๋ฐ์ดํฐํฌํธ
- Request access to these 3 APIs (all use the same key):
- ๊ธฐ์์ฒญ ๋จ๊ธฐ์๋ณด ์กฐํ์๋น์ค (15084084)
- ๊ธฐ์์ฒญ ๊ธฐ์ํน๋ณด ์กฐํ์๋น์ค (15000415)
- ๊ธฐ์์ฒญ ์ค๊ธฐ์๋ณด ์กฐํ์๋น์ค (15059468)
- Copy your
ServiceKeyfrom My Page โ API Key Management
2. Set Environment Variable
In ~/.openclaw/openclaw.json:
Sandbox (add to agents.defaults.sandbox.docker.env):
{
"agents": {
"defaults": {
"sandbox": {
"docker": {
"env": {
"KMA_SERVICE_KEY": "your-key"
}
}
}
}
}
}
Host (add to env.vars):
{
"env": {
"vars": {
"KMA_SERVICE_KEY": "your-key"
}
}
}
Usage
forecast.py
| Command | Description |
|---|---|
current |
Real-time observations |
ultrashort |
6-hour forecast |
shortterm |
3-day forecast |
brief |
current + ultrashort |
all |
current + ultrashort + shortterm |
Options:
--lat,--lon: Coordinates (required)--days: For shortterm -1(tomorrow, default),2,3, orall--json: Raw JSON output
Output example (current):
๐ค๏ธ ํ์ฌ ๋ ์จ (์ด๋จ๊ธฐ์คํฉ)
๐ก๏ธ ๊ธฐ์จ: 5.2ยฐC
๐ง ์ต๋: 65%
๐ง๏ธ ๊ฐ์๋: 0mm (1์๊ฐ)
๐จ ํ์: 2.3m/s
๐งญ ํํฅ: NW (315ยฐ)
weather_warnings.py
Returns current nationwide ๊ธฐ์ํน๋ณด:
๐จ ๊ธฐ์ํน๋ณด ํํฉ
๋ฐํ์๊ฐ: 2026-02-01 10:00
๋ฐํจ์๊ฐ: 2026-02-01 10:00
๐ ํ์ฌ ๋ฐํจ ์ค์ธ ํน๋ณด
โข ๊ฑด์กฐ๊ฒฝ๋ณด : ๊ฐ์๋, ๊ฒฝ์๋ถ๋, ...
โข ํ๋์ฃผ์๋ณด : ๋ํด์ค๋ถ์์ชฝ๋จผ๋ฐ๋ค, ...
โ ๏ธ ์๋นํน๋ณด
โข (1) ๊ฐํ ์๋นํน๋ณด : 02์ 02์ผ ์๋ฒฝ(00์~06์) : ์ธ๋ฆ๋.๋
๋
midterm.py
3-10 day forecast by region.
python3 skills/kma-weather/scripts/midterm.py --region ์์ธ
python3 skills/kma-weather/scripts/midterm.py --stn-id 109
Regions: ์์ธ, ์ธ์ฒ, ๊ฒฝ๊ธฐ, ๋ถ์ฐ, ๋๊ตฌ, ๊ด์ฃผ, ๋์ , ์ธ์ฐ, ์ธ์ข , ๊ฐ์, ์ถฉ๋ถ, ์ถฉ๋จ, ์ ๋ถ, ์ ๋จ, ๊ฒฝ๋ถ, ๊ฒฝ๋จ, ์ ์ฃผ
grid_converter.py
Convert lat/lon to KMA 5km grid (auto-handled by other scripts):
python3 skills/kma-weather/scripts/grid_converter.py 37.5665 126.9780
# Output: Grid: (60, 127)
API Notes
- Release Schedule:
- Current: Every hour at :40 (base_time: HH00)
- Ultra-short: Every hour at :45 (base_time: HH30)
- Short-term: 02:10, 05:10, 08:10, 11:10, 14:10, 17:10, 20:10, 23:10 (KST)
- Mid-term: 06:00, 18:00 (KST)
- Coverage: South Korea only
- Auto-pagination: Scripts fetch all pages automatically
vs weather skill
| weather | kma-weather | |
|---|---|---|
| Coverage | Global | Korea only |
| API Key | No | Required |
| Resolution | City-level | 5km grid |
| Weather Warnings | No | Yes (๊ธฐ์ํน๋ณด) |
Use both: weather for global, kma-weather for detailed Korean forecasts and ๊ธฐ์ํน๋ณด.
Troubleshooting
| Error | Solution |
|---|---|
KMA API service key not found |
Set KMA_SERVICE_KEY env var |
SERVICE_KEY_IS_NOT_REGISTERED_ERROR |
Check API approval status, verify key |
SERVICE_TIMEOUT_ERROR |
Retry later |
| No data returned | Verify coordinates are in South Korea |
References (Raw API Documentation)
- references/api-forecast.md - ๋จ๊ธฐ์๋ณด API endpoints, parameters, response format
- references/api-warnings.md - ๊ธฐ์ํน๋ณด API endpoints, parameters, response format
- references/api-midterm.md - ์ค๊ธฐ์๋ณด API endpoints, parameters, response format
- references/category-codes.md - KMA category codes (SKY, PTY, etc.)
- implement-status.md - Implementation status