k-skill/docs/features/kbl-results.md
Jeffrey (Dongkyu) Kim 7c0bfa4c93
Feature/#129 (#131)
* Add official KBL results support so basketball queries use live league data

Issue #129 needs a read-only skill and reusable package for KBL schedules, results, and standings. The implementation follows the existing sports package pattern and uses the league's live JSON APIs after verifying they respond successfully in real requests.

Constraint: Must use official KBL JSON surfaces before considering scraping
Constraint: Packaging changes must pass npm run ci and include docs plus Changesets updates
Rejected: Browser scraping first | official api.kbl.or.kr endpoints are live and simpler to maintain
Rejected: Reuse KBO/K League package shapes verbatim | KBL payload and team/status fields differ materially
Confidence: high
Scope-risk: moderate
Reversibility: clean
Directive: Keep seasonGrade=1 as the default KBL path unless future docs/tests explicitly widen to D-League flows
Tested: npm run ci; npm run lint --workspace kbl-results; npm test --workspace kbl-results; live getKBLSummary("2026-04-01", { team: "KCC", includeStandings: true })
Not-tested: Historical standings snapshots for past seasons via alternative KBL endpoints

* Prevent optional standings lookups from over-fetching the KBL API

The new kbl-results summary helper exposes includeStandings=false, so the
regression suite now proves that path stays schedule-only and never calls
the standings endpoint when the caller opts out.

Constraint: The KBL package should preserve the caller's no-standings contract
Rejected: Rely on manual inspection of the helper options | a targeted test is cheaper and safer
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Keep includeStandings=false side-effect free unless the public API contract changes explicitly
Tested: npm test --workspace kbl-results; npm run lint --workspace kbl-results
Not-tested: Full-repo CI before stacking this commit onto the rebased branch
2026-04-18 11:20:42 +09:00

1.9 KiB

KBL 경기 결과 가이드

이 기능으로 할 수 있는 일

  • 날짜별 KBL 경기 일정 및 결과 조회
  • 특정 팀(서울 SK, 부산 KCC, 팀 코드 등) 경기만 필터링
  • 현재 순위 확인

먼저 필요한 것

  • Node.js 18+
  • npm install -g kbl-results

입력값

  • 날짜: YYYY-MM-DD
  • 선택 사항: 팀명, 풀네임, 팀 코드

공식 표면

이 기능은 브라우저 크롤링 전에 공식 JSON 표면을 직접 사용한다.

  • KBL 일정/결과 API: https://api.kbl.or.kr/match/list
  • KBL 팀 순위 API: https://api.kbl.or.kr/league/rank/team

기본 흐름

  1. 패키지가 없으면 다른 방법으로 우회하지 말고 먼저 kbl-results 를 전역 설치한다.
  2. match/listfromDate / toDate / tcodeList / seasonGrade=1 을 넣어 날짜별 경기 데이터를 가져온다.
  3. 요청 팀이 있으면 서울 SK, SK, 55, 부산 KCC, KCC 같은 alias 를 같은 팀으로 인식해 걸러낸다.
  4. league/rank/team 으로 현재 순위를 가져와 경기 결과와 함께 보여준다.

예시

GLOBAL_NPM_ROOT="$(npm root -g)" node --input-type=module - <<'JS'
import path from "node:path";
import { pathToFileURL } from "node:url";

const entry = pathToFileURL(
  path.join(process.env.GLOBAL_NPM_ROOT, "kbl-results", "src", "index.js"),
).href;
const { getKBLSummary } = await import(entry);

const summary = await getKBLSummary("2026-04-01", {
  team: "서울 SK",
  includeStandings: true,
});

console.log(JSON.stringify(summary, null, 2));
JS

주의할 점

  • match/listYYYYMMDD 파라미터를 받는다. 라이브러리가 YYYY-MM-DD 입력을 공식 포맷으로 바꾼다.
  • 기본 조회는 KBL 1군 기준이라 seasonGrade=1 을 사용한다.
  • 현재 순위는 league/rank/team 기준 현재 표를 사용한다.
  • 공식 JSON이 살아 있으므로 브라우저 scraping 은 기본 경로가 아니다.