Skill: chloepark85/kamis-cli (version 0.1.0)

--- name: kamis-cli description: Korean agricultural/livestock/aquatic wholesale & retail price data via the official KAMIS (한국농수산식품유통공사) OpenAPI. Use for daily 도매가/소매가 lookup, 7-day & monthly & yearly trends, regional price comparison, and code lookup. Free p_cert_key from kamis.or.kr. Use when the user asks about Korean food/produce prices, market prices, agri price trends, restaurant ingredient costs, KAMIS, 농산물 가격, or 도매시장. license: MIT --- # KAMIS CLI — 한국 농수산물 가격 OpenAPI Wraps **KAMIS** (Korea Agro-Fisheries & Food Trade Corporation, [kamis.or.kr](https://www.kamis.or.kr)) — the canonical source for Korean agricultural, livestock, and aquatic product prices. Daily wholesale/retail prices for ~180 items across 10 부류, with built-in 1-day/1-week/2-week/1-month/1-year/평년 comparisons. Endpoint: `https://www.kamis.or.kr/service/price/xml.do?action={ACTION}&p_cert_key={KEY}&p_cert_id={ID}&p_returntype=json&...` ## Setup (once) 1. Apply for an API key at https://www.kamis.or.kr/customer/reference/openapi_list.do (1-business-day approval, free). 2. Export credentials in your shell: ```bash export KAMIS_CERT_KEY="your-key" export KAMIS_CERT_ID="your-email-id" ``` The CLI also accepts `--key` / `--id` flags. If unset, it falls back to `TEST`/`TEST` which works for `dailyPriceByCategoryList` (the most common call) but is rate-limited and may return `error_code:001` for paid endpoints. ## Subcommands All subcommands return JSON to stdout. Pipe through `jq` for shaping. ### 1. `daily.sh` — 일일 부류별 도/소매가격 (`dailyPriceByCategoryList`) The flagship endpoint. One call returns every item in a 부류 (category) with **today / 1 day ago / 1 week ago / 2 weeks ago / 1 month ago / 1 year ago / 평년** prices side-by-side. Perfect for AI agents asking "what's happening with onion prices this week?" ```bash scripts/daily.sh --cls 01 --category 200 --date 2026-04-30 # 01 = 소매(retail), 02 = 도매(wholesale) # category: 100=식량작물, 200=채소류, 300=특용작물, 400=과일류, 500=축산물, 600=수산물 # Optional: --country 1101 (서울), --kg-convert Y ``` ### 2. `period.sh` — 기간별 도매가격 (`periodProductList`) Daily prices for a specific item across a date range (≤ 1 year). Returns one row per market per day. ```bash scripts/period.sh \ --start 2026-01-01 --end 2026-04-30 \ --category 200 --item 211 --kind 01 --rank 04 --country 1101 # 211 = 양파, 01 = 일반양파, 04 = 상품, 1101 = 서울 ``` ### 3. `period-retail.sh` — 기간별 소매가격 (`periodRetailProductList`) Same shape as `period.sh` but soft-retail (대형마트/전통시장) instead of 도매. Use when comparing 소매 마진. ```bash scripts/period-retail.sh --start 2026-04-01 --end 2026-04-30 --category 200 --item 211 --kind 01 --rank 04 --country 1101 ``` ### 4. `monthly.sh` — 월별 평균 가격 (`monthlySalesList`) Long-term monthly averages — use for seasonality charts, YoY comparison. ```bash scripts/monthly.sh --year 2026 --period 2024,2025 --category 200 --item 211 --kind 01 ``` ### 5. `yearly.sh` — 연도별 평균 가격 (`yearlySalesList`) Annual averages. ```bash scripts/yearly.sh --year 2026 --category 200 --item 211 --kind 01 ``` ### 6. `recent.sh` — 최근 가격 동향 간이조회 (`recentlyPriceTrendList`) Lightweight time-series for a single product number — last 40 days, 30 days, 20 days, 10 days, 0 days, plus min/max. Useful for fast charts without fetching the full period dataset. ```bash scripts/recent.sh --product 111 # 111 = 쌀 ``` ### 7. `codes.sh` — 코드 표 (helper, no API call) Local lookup of category / item / kind / rank / country codes. Wraps `reference/codes.json` — the canonical KAMIS code table cached at skill install. ```bash scripts/codes.sh categories scripts/codes.sh items --category 200 scripts/codes.sh countries # 17 시·군 codes scripts/codes.sh ranks ``` ## Quick recipes **"How much have onion prices moved this week?"** ```bash scripts/daily.sh --cls 01 --category 200 | jq '.data.item[] | select(.item_name=="양파")' ``` **"Plot 1-year retail price for rice"** ```bash scripts/period.sh --start 2025-05-01 --end 2026-04-30 --category 100 --item 111 --kind 01 --rank 04 --country 1101 | jq '.data.item[] | {date: .yyyy + "-" + .regday, price: .price}' ``` **"Daily morning brief: top 5 climbers in 채소류"** ```bash scripts/daily.sh --cls 02 --category 200 \ | jq '[.data.item[] | {name: .item_name, kind: .kind_name, today: (.dpr1|gsub(",";"")|tonumber), week_ago: (.dpr3|gsub(",";"")|tonumber)} | .pct = ((.today - .week_ago) / .week_ago * 100)] | sort_by(-.pct) | .[0:5]' ``` See `examples/restaurant-cost-tracker.sh` for a full pipeline that emits a daily Slack/Telegram-ready summary. ## Pairs naturally with - **`opendart-cli`** — overlay 식료품 corporate disclosure with raw input prices. - **`bank-of-korea-ecos-cli`** — compare CPI-Food vs raw 농산물 도매가. - **`kr-holiday-cli`** — exclude 명절 demand spikes from trend lines. - **`naver-datalab-cli`** — correlate 검색량 (e.g., "양파 가격") with the price spike. - **`kakao-local-cli`** — map 도매시장 locations. - **`tistory-api-cli` / `velog-cli`** — auto-publish a daily-price digest. ## Notes & gotchas - The TEST key works for `dailyPriceByCategoryList` (immediate snapshot) but several "기간" endpoints return `error_code:"001"` until you swap in your own key. - KAMIS only retains 1 year of recent data through the public API. For older data, contact KAMIS directly (061-930-9971). - `p_returntype=json` is supported but the API still ships an `xml.do` path — that's the actual route, not a typo. - Numbers come as comma-formatted strings (`"62,421"`) — strip with `jq 'gsub(","; "") | tonumber'` before arithmetic. - A few endpoints inconsistently use `p_country_code` vs `p_countycode` — the scripts normalize this for you.

path: README.md
content: # kamis-cli

CLI wrapper for the official **KAMIS** (한국농수산식품유통공사 / Korea Agro-Fisheries & Food Trade Corporation) OpenAPI — daily wholesale & retail prices for ~180 농수축산물 across 6 부류, with built-in 7-day, 1-month, 1-year, and 평년 comparisons.

> Endpoint: `https://www.kamis.or.kr/service/price/xml.do`

## Why
- **AI agents** asking about Korean food/produce prices, restaurant ingredient costs, agri inflation
- **Restaurants & buyers** doing daily 도매가 spot-checks
- **Inflation reporters** comparing wholesale vs CPI-Food
- **Content creators** writing about 김장 cost, 명절 시세, etc.

## Setup
1. Apply for a free API key at https://www.kamis.or.kr/customer/reference/openapi_list.do (1-day approval).
2. `export KAMIS_CERT_KEY="..."` and `export KAMIS_CERT_ID="..."`.

The TEST/TEST credentials work for `dailyPriceByCategoryList` (smoke-tests the flow); other endpoints need a real key.

## Quick start
```bash
# 오늘 채소류 도매가 한 번에
./scripts/daily.sh --cls 02 --category 200

# 양파(서울) 4월 한 달 도매가
./scripts/period.sh --start 2026-04-01 --end 2026-04-30 \
  --category 200 --item 211 --kind 01 --rank 04 --country 1101

# 쌀 최근 가격 동향
./scripts/recent.sh --product 111
```

See `SKILL.md` for the full subcommand reference and recipe library.

## Examples
- `examples/restaurant-cost-tracker.sh` — daily Markdown cost brief for chefs/buyers (8 staple items)
- `examples/cpi-vs-wholesale.sh` — overlay 양파 도매 trend with BOK ECOS CPI-Food (requires bank-of-korea-ecos-cli)

## Pairs with
- `opendart-cli` `bank-of-korea-ecos-cli` `kr-holiday-cli` `naver-datalab-cli` `kakao-local-cli`

MIT.


path: examples/cpi-vs-wholesale.sh
content: #!/usr/bin/env bash
# Compare KAMIS 도매가 trend with BOK ECOS CPI-Food.
#
# Pairs kamis-cli + bank-of-korea-ecos-cli (assumes both installed). Demonstrates
# that wholesale agri prices are the leading indicator that consumer-CPI follows
# 1-2 months later — useful for inflation reporters & macro analysts.
#
# Usage: ./cpi-vs-wholesale.sh <item-code>
# Example: ./cpi-vs-wholesale.sh 211   # 양파
set -euo pipefail
SKILL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
ITEM="${1:-211}"

YEAR=$(date +%Y)
LAST_YEAR=$((YEAR - 1))

echo "# 양파(${ITEM}) — 도매가 vs 식료품 CPI"
echo

# 1) KAMIS monthly wholesale, last 2 years.
echo "## KAMIS 월별 도매 평균"
"${SKILL_DIR}/scripts/monthly.sh" --year "${YEAR}" --period "${LAST_YEAR},${YEAR}" --category 200 --item "${ITEM}" --kind 01 \
  | jq -r '.data[] | select(.item_name) | "\(.yyyymm): \(.price)원"' 2>/dev/null || echo "(API key needed for monthly endpoint)"

echo
echo "## BOK ECOS — 식료품·비주류음료 CPI (요청예시)"
echo "  bank-of-korea-ecos-cli/scripts/series.sh --series 901Y009 --item E11 --start ${LAST_YEAR}01 --end ${YEAR}12"
echo
echo "_도매가 변화는 통상 1-2개월 시차로 CPI에 전이됨._"


path: examples/restaurant-cost-tracker.sh
content: #!/usr/bin/env bash
# Restaurant cost tracker — emits a daily Markdown brief for chefs/buyers.
#
# Tracks 양파, 대파, 마늘, 배추, 무, 돼지고기, 닭고기, 달걀 — pulls today's 도매가
# alongside 1-week-ago and 1-month-ago, computes % deltas, and flags anything
# moving >5% week-over-week as a 🔥 alert.
#
# Pairs naturally with cron + telegram/slack hooks.
set -euo pipefail
SKILL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

categories=("100" "200" "200" "200" "200" "200" "500" "500" "500")
labels=("쌀(20kg)" "양파(상품)" "대파(상품)" "마늘(깐마늘)" "배추(상품)" "무(상품)" "돼지고기(삼겹)" "닭고기(육계)" "달걀(특란)")

today=$(date +%F)
echo "# 🍳 식자재 도매가 일일 브리핑 — ${today}"
echo
echo "| 품목 | 오늘 | 1주전 | 1달전 | WoW |"
echo "|---|---:|---:|---:|---:|"

# Single API call per 부류 — collect everything in one shot.
declare -A seen
for cat in "100" "200" "500"; do
  json=$("${SKILL_DIR}/scripts/daily.sh" --cls 02 --category "${cat}" --date "${today}" 2>/dev/null || echo "{}")
  echo "$json" | jq -r '
    .data.item // [] |
    map(select(.kind_code != null)) |
    .[] |
    (.dpr1|gsub(",";"")|tonumber? // 0) as $today |
    (.dpr3|gsub(",";"")|tonumber? // 0) as $week |
    (.dpr5|gsub(",";"")|tonumber? // 0) as $month |
    (if $week > 0 then (($today - $week) / $week * 100) else 0 end) as $wow |
    "\(.item_name) (\(.kind_name))|\(.dpr1)|\(.dpr3)|\(.dpr5)|\($wow|.*100|round/100)%"
  ' 2>/dev/null | while IFS='|' read -r name today_p week_p month_p wow; do
    flag=""
    case "$wow" in
      *-*[0-9]*\%) [[ "${wow//[^0-9.-]/}" =~ ^-?[0-9]+\.?[0-9]*$ ]] && awk "BEGIN{exit !(${wow%\%} >= 5 || ${wow%\%} <= -5)}" 2>/dev/null && flag=" 🔥";;
    esac
    echo "| $name | ${today_p} | ${week_p} | ${month_p} | ${wow}${flag} |"
  done
done

echo
echo "_데이터: KAMIS (kamis.or.kr) • 단가는 조사 시점의 도매가격_"


path: reference/codes.json
content: {
  "categories": [
    {"code": "100", "name": "식량작물", "en": "Grains"},
    {"code": "200", "name": "채소류", "en": "Vegetables"},
    {"code": "300", "name": "특용작물", "en": "Specialty crops"},
    {"code": "400", "name": "과일류", "en": "Fruits"},
    {"code": "500", "name": "축산물", "en": "Livestock"},
    {"code": "600", "name": "수산물", "en": "Aquatic"}
  ],
  "items": [
    {"category": "100", "code": "111", "name": "쌀"},
    {"category": "100", "code": "112", "name": "찹쌀"},
    {"category": "100", "code": "141", "name": "콩"},
    {"category": "100", "code": "142", "name": "팥"},
    {"category": "100", "code": "143", "name": "녹두"},
    {"category": "100", "code": "151", "name": "고구마"},
    {"category": "100", "code": "152", "name": "감자"},

    {"category": "200", "code": "211", "name": "양파"},
    {"category": "200", "code": "212", "name": "대파"},
    {"category": "200", "code": "213", "name": "쪽파"},
    {"category": "200", "code": "215", "name": "마늘"},
    {"category": "200", "code": "221", "name": "건고추"},
    {"category": "200", "code": "222", "name": "풋고추"},
    {"category": "200", "code": "223", "name": "붉은고추"},
    {"category": "200", "code": "225", "name": "오이"},
    {"category": "200", "code": "226", "name": "호박"},
    {"category": "200", "code": "231", "name": "배추"},
    {"category": "200", "code": "232", "name": "양배추"},
    {"category": "200", "code": "233", "name": "시금치"},
    {"category": "200", "code": "234", "name": "상추"},
    {"category": "200", "code": "235", "name": "얼갈이배추"},
    {"category": "200", "code": "241", "name": "당근"},
    {"category": "200", "code": "242", "name": "무"},
    {"category": "200", "code": "243", "name": "토마토"},
    {"category": "200", "code": "244", "name": "방울토마토"},
    {"category": "200", "code": "245", "name": "수박"},
    {"category": "200", "code": "247", "name": "딸기"},
    {"category": "200", "code": "248", "name": "참외"},
    {"category": "200", "code": "251", "name": "버섯"},
    {"category": "200", "code": "252", "name": "팽이버섯"},
    {"category": "200", "code": "253", "name": "느타리버섯"},

    {"category": "300", "code": "311", "name": "참깨"},
    {"category": "300", "code": "312", "name": "들깨"},
    {"category": "300", "code": "313", "name": "땅콩"},

    {"category": "400", "code": "411", "name": "사과"},
    {"category": "400", "code": "412", "name": "배"},
    {"category": "400", "code": "413", "name": "복숭아"},
    {"category": "400", "code": "414", "name": "포도"},
    {"category": "400", "code": "415", "name": "감귤"},
    {"category": "400", "code": "416", "name": "단감"},
    {"category": "400", "code": "417", "name": "참다래"},
    {"category": "400", "code": "418", "name": "바나나"},
    {"category": "400", "code": "419", "name": "오렌지"},

    {"category": "500", "code": "511", "name": "쇠고기"},
    {"category": "500", "code": "514", "name": "돼지고기"},
    {"category": "500", "code": "515", "name": "닭고기"},
    {"category": "500", "code": "516", "name": "달걀"},

    {"category": "600", "code": "611", "name": "갈치"},
    {"category": "600", "code": "612", "name": "고등어"},
    {"category": "600", "code": "613", "name": "조기"},
    {"category": "600", "code": "614", "name": "명태"},
    {"category": "600", "code": "621", "name": "오징어"},
    {"category": "600", "code": "622", "name": "물오징어"},
    {"category": "600", "code": "631", "name": "건멸치"},
    {"category": "600", "code": "641", "name": "굴"},
    {"category": "600", "code": "642", "name": "전복"}
  ],
  "ranks": [
    {"code": "04", "name": "상품"},
    {"code": "05", "name": "중품"}
  ],
  "countries": [
    {"code": "1101", "name": "서울"},
    {"code": "2100", "name": "부산"},
    {"code": "2200", "name": "대구"},
    {"code": "2300", "name": "인천"},
    {"code": "2401", "name": "광주"},
    {"code": "2501", "name": "대전"},
    {"code": "2601", "name": "울산"},
    {"code": "3111", "name": "수원"},
    {"code": "3211", "name": "춘천"},
    {"code": "3311", "name": "청주"},
    {"code": "3411", "name": "전주"},
    {"code": "3511", "name": "포항"},
    {"code": "3613", "name": "제주"},
    {"code": "3711", "name": "의정부"},
    {"code": "3911", "name": "순천"},
    {"code": "4111", "name": "안동"},
    {"code": "4311", "name": "용인"}
  ],
  "_note": "Curated subset of the most-queried KAMIS codes. The official KAMIS code table has more variants (kind/grade combinations); call /codes/itemList through the KAMIS portal for the canonical lookup."
}


path: scripts/_common.sh
content: #!/usr/bin/env bash
# Shared helpers for kamis-cli scripts.
set -euo pipefail

KAMIS_BASE="${KAMIS_BASE:-https://www.kamis.or.kr/service/price/xml.do}"

kamis_creds() {
  local key="${KAMIS_CERT_KEY:-${1:-}}"
  local id="${KAMIS_CERT_ID:-${2:-}}"
  if [[ -z "$key" ]]; then key="TEST"; fi
  if [[ -z "$id" ]]; then id="TEST"; fi
  printf '%s\t%s\n' "$key" "$id"
}

# kamis_call <action> [extra query args ...]
# Reads --key/--id from KAMIS_CERT_KEY/KAMIS_CERT_ID or falls back to TEST.
kamis_call() {
  local action="$1"; shift
  local key="${KAMIS_CERT_KEY:-TEST}"
  local id="${KAMIS_CERT_ID:-TEST}"
  local url="${KAMIS_BASE}?action=${action}&p_cert_key=${key}&p_cert_id=${id}&p_returntype=json"
  for arg in "$@"; do url+="&${arg}"; done
  curl -sS --max-time 30 \
    -H "User-Agent: Mozilla/5.0 (kamis-cli)" \
    -H "Accept: application/json" \
    "$url"
}

require_arg() {
  local name="$1" val="${2:-}"
  if [[ -z "$val" ]]; then
    echo "missing required arg: --${name}" >&2
    exit 2
  fi
}


path: scripts/codes.sh
content: #!/usr/bin/env bash
# Local code lookup. No API call. Reads reference/codes.json.
#
# Usage:
#   codes.sh categories                  # 부류 (식량/채소/특용/과일/축산/수산)
#   codes.sh items [--category <code>]   # 품목 (filtered if --category given)
#   codes.sh countries                   # 시도 (1101 서울, 2300 대전, ...)
#   codes.sh ranks                       # 등급 (04 상품, 05 중품)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DATA="${SCRIPT_DIR}/../reference/codes.json"

[[ -f "$DATA" ]] || { echo "missing reference/codes.json" >&2; exit 1; }
command -v jq >/dev/null || { echo "jq required" >&2; exit 1; }

mode="${1:-}"
shift || true

case "$mode" in
  categories)
    jq '.categories' "$DATA";;
  items)
    cat_filter=""
    while [[ $# -gt 0 ]]; do
      case "$1" in
        --category) cat_filter="$2"; shift 2;;
        *) shift;;
      esac
    done
    if [[ -n "$cat_filter" ]]; then
      jq --arg c "$cat_filter" '.items[] | select(.category == $c)' "$DATA"
    else
      jq '.items' "$DATA"
    fi;;
  countries) jq '.countries' "$DATA";;
  ranks) jq '.ranks' "$DATA";;
  ""|-h|--help)
    sed -n '2,9p' "$0"; exit 0;;
  *) echo "unknown mode: $mode" >&2; exit 2;;
esac


path: scripts/daily.sh
content: #!/usr/bin/env bash
# 일일 부류별 도/소매가격 (action=dailyPriceByCategoryList).
#
# Required: --category <100|200|300|400|500|600>
# Optional: --cls <01|02> (01=retail, 02=wholesale; default 01)
#           --date YYYY-MM-DD (default: today)
#           --country <code> (e.g. 1101=서울. omit for all)
#           --kg-convert Y|N (default N)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=_common.sh
source "${SCRIPT_DIR}/_common.sh"

cls="01"
category=""
date_arg="$(date +%F)"
country=""
kg="N"

while [[ $# -gt 0 ]]; do
  case "$1" in
    --cls) cls="$2"; shift 2;;
    --category) category="$2"; shift 2;;
    --date) date_arg="$2"; shift 2;;
    --country) country="$2"; shift 2;;
    --kg-convert) kg="$2"; shift 2;;
    -h|--help)
      sed -n '2,11p' "$0"
      exit 0;;
    *) echo "unknown arg: $1" >&2; exit 2;;
  esac
done

require_arg category "$category"

args=(
  "p_product_cls_code=${cls}"
  "p_regday=${date_arg}"
  "p_convert_kg_yn=${kg}"
  "p_item_category_code=${category}"
)
[[ -n "$country" ]] && args+=("p_country_code=${country}")

kamis_call dailyPriceByCategoryList "${args[@]}"


path: scripts/monthly.sh
content: #!/usr/bin/env bash
# 월별 평균 가격 (action=monthlySalesList).
#
# Required: --year YYYY --category <code>
# Optional: --period "YYYY,YYYY"   compare years (e.g. 2024,2025)
#           --item <code> --kind <code>
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/_common.sh"

year=""; period=""; category=""; item=""; kind=""
while [[ $# -gt 0 ]]; do
  case "$1" in
    --year) year="$2"; shift 2;;
    --period) period="$2"; shift 2;;
    --category) category="$2"; shift 2;;
    --item) item="$2"; shift 2;;
    --kind) kind="$2"; shift 2;;
    -h|--help) sed -n '2,7p' "$0"; exit 0;;
    *) echo "unknown arg: $1" >&2; exit 2;;
  esac
done

require_arg year "$year"
require_arg category "$category"

args=("p_yyyy=${year}" "p_itemcategorycode=${category}")
[[ -n "$period" ]] && args+=("p_period=${period}")
[[ -n "$item" ]] && args+=("p_itemcode=${item}")
[[ -n "$kind" ]] && args+=("p_kindcode=${kind}")

kamis_call monthlySalesList "${args[@]}"


path: scripts/period-retail.sh
content: #!/usr/bin/env bash
# 기간별 소매가격 (action=periodRetailProductList).
# Same shape as period.sh.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/_common.sh"

start=""; end=""; category=""; item=""; kind=""; rank=""; country=""; kg="N"
while [[ $# -gt 0 ]]; do
  case "$1" in
    --start) start="$2"; shift 2;;
    --end) end="$2"; shift 2;;
    --category) category="$2"; shift 2;;
    --item) item="$2"; shift 2;;
    --kind) kind="$2"; shift 2;;
    --rank) rank="$2"; shift 2;;
    --country) country="$2"; shift 2;;
    --kg-convert) kg="$2"; shift 2;;
    -h|--help) sed -n '2,4p' "$0"; exit 0;;
    *) echo "unknown arg: $1" >&2; exit 2;;
  esac
done

for n in start end category item kind rank country; do require_arg "$n" "${!n}"; done

kamis_call periodRetailProductList \
  "p_startday=${start}" \
  "p_endday=${end}" \
  "p_itemcategorycode=${category}" \
  "p_itemcode=${item}" \
  "p_kindcode=${kind}" \
  "p_productrankcode=${rank}" \
  "p_countrycode=${country}" \
  "p_convert_kg_yn=${kg}"


path: scripts/period.sh
content: #!/usr/bin/env bash
# 기간별 도매가격 (action=periodProductList).
#
# Required: --start YYYY-MM-DD --end YYYY-MM-DD
#           --category <code> --item <code> --kind <code> --rank <code> --country <code>
# Optional: --kg-convert Y|N (default N)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/_common.sh"

start=""; end=""; category=""; item=""; kind=""; rank=""; country=""; kg="N"
while [[ $# -gt 0 ]]; do
  case "$1" in
    --start) start="$2"; shift 2;;
    --end) end="$2"; shift 2;;
    --category) category="$2"; shift 2;;
    --item) item="$2"; shift 2;;
    --kind) kind="$2"; shift 2;;
    --rank) rank="$2"; shift 2;;
    --country) country="$2"; shift 2;;
    --kg-convert) kg="$2"; shift 2;;
    -h|--help) sed -n '2,9p' "$0"; exit 0;;
    *) echo "unknown arg: $1" >&2; exit 2;;
  esac
done

for n in start end category item kind rank country; do
  require_arg "$n" "${!n}"
done

kamis_call periodProductList \
  "p_startday=${start}" \
  "p_endday=${end}" \
  "p_itemcategorycode=${category}" \
  "p_itemcode=${item}" \
  "p_kindcode=${kind}" \
  "p_productrankcode=${rank}" \
  "p_countrycode=${country}" \
  "p_convert_kg_yn=${kg}"


path: scripts/recent.sh
content: #!/usr/bin/env bash
# 최근 가격 동향 간이조회 (action=recentlyPriceTrendList).
#
# Required: --product <productno>   (e.g. 111 = 쌀)
# Optional: --date YYYY-MM-DD       (anchor; default = today)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/_common.sh"

product=""; date_arg="$(date +%F)"
while [[ $# -gt 0 ]]; do
  case "$1" in
    --product) product="$2"; shift 2;;
    --date) date_arg="$2"; shift 2;;
    -h|--help) sed -n '2,5p' "$0"; exit 0;;
    *) echo "unknown arg: $1" >&2; exit 2;;
  esac
done

require_arg product "$product"

kamis_call recentlyPriceTrendList \
  "p_productno=${product}" \
  "p_regday=${date_arg}"


path: scripts/yearly.sh
content: #!/usr/bin/env bash
# 연도별 평균 가격 (action=yearlySalesList).
#
# Required: --year YYYY --category <code>
# Optional: --item <code> --kind <code>
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/_common.sh"

year=""; category=""; item=""; kind=""
while [[ $# -gt 0 ]]; do
  case "$1" in
    --year) year="$2"; shift 2;;
    --category) category="$2"; shift 2;;
    --item) item="$2"; shift 2;;
    --kind) kind="$2"; shift 2;;
    -h|--help) sed -n '2,5p' "$0"; exit 0;;
    *) echo "unknown arg: $1" >&2; exit 2;;
  esac
done

require_arg year "$year"
require_arg category "$category"

args=("p_yyyy=${year}" "p_itemcategorycode=${category}")
[[ -n "$item" ]] && args+=("p_itemcode=${item}")
[[ -n "$kind" ]] && args+=("p_kindcode=${kind}")

kamis_call yearlySalesList "${args[@]}"


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: clean (LOW)