datagokr — 기상청 중기예보
Fetch the 4-to-10-day outlook for a forecast region. Where the weather skill covers the
next ~3 days on a 5km grid, this covers days 4-10 for a coarser 예보구역 named by a
region code. The rows are wide -- one row per region, a column per forecast day:
| operation | 예보 | clean columns |
|---|---|---|
land |
중기육상예보 | regid, precip_prob_4am..precip_prob_10 (강수확률 %, int), sky_4am..sky_10 (날씨 문구) |
temperature |
중기기온예보 | regid, temp_min_4..temp_min_10, temp_max_4..temp_max_10 (℃, int) |
Days 4-7 split into morning/afternoon (_4am/_4pm .. _7am/_7pm); days 8-10 are
single (_8.._10). A day the announcement does not cover is None (the 1800 announcement
starts at day 5, the 0600 one reaches day 4).
Prerequisite
pipx install pydatagokr # or: pip install pydatagokr
Never print the key value (the DATAGOKR_API_KEY env var or credentials.json) to output, logs, or a summary -- if you need to check which form it is (encoding vs decoding), ask the user.
A data.go.kr decoding key must be configured (env DATAGOKR_API_KEY or
~/.config/pydatagokr/credentials.json), and the 중기예보 dataset (service 1360000,
MidFcstInfoService) applied for (활용신청) on that account.
Running
datagokr midforecast land --regid REGID --time-forecast YYYYMMDDHHMM [--json]
datagokr midforecast temperature --regid REGID --time-forecast YYYYMMDDHHMM [--json]
--regid: the 예보구역코드. 육상 uses a 광역 code (11B00000서울/인천/경기,11H20000부산/울산/경남, ...); 기온 uses a 도시 code (11B10101서울,11H20201부산, ...). Ask if unsure; do not guess a code.--time-forecast: the 발표시각 asYYYYMMDDHHMM, issued at 0600 and 1800 (e.g.202608111800).
Procedure
- Resolve the region code for the operation with the offline resolver -- the 육상 광역 and
기온 도시 code sets differ, so use
datagokr land-region 서울->11B00000forland, ordatagokr temp-region 서울->11B10101fortemperature. Pick a recentbase-time(today or yesterday at 0600/1800). - Run.
Adddatagokr midforecast land --regid 11B00000 --time-forecast 202608111800--jsonfor machine-readable data. - Relay the result. Read the day columns in order; a
Noneday was outside the announcement's range. - Error handling. A one-line
datagokr: <message>on stderr:- a
[30]/[20]auth error -> the key is wrong, is the encoding form, or service 1360000 is not applied for yet. - an empty result usually means a
base-timethat is not a real 0600/1800 announcement.
- a
What this skill does not do
- It does not re-implement fetching or parsing (the package does); it always calls the CLI.
- It resolves a place name to a REGID via
datagokr land-region/datagokr temp-region; it does not geocode a vague or free-form location. - It does not cover 초단기/단기 (next ~3 days) -- that is the
weatherskill.