k-skill/packages/kbl-results/README.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.4 KiB

kbl-results

공식 KBL JSON 엔드포인트를 감싼 재사용 가능한 Node.js 클라이언트입니다. 날짜별 경기 결과와 현재 순위를 함께 조회할 수 있습니다.

Install

npm install kbl-results

Official surfaces

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

Usage

const { getKBLSummary, getMatchResults, getStandings } = require("kbl-results");

(async () => {
  const results = await getMatchResults("2026-04-01", {
    team: "서울 SK",
  });

  const standings = await getStandings();

  const summary = await getKBLSummary("2026-04-01", {
    team: "부산 KCC",
    includeStandings: true,
  });

  console.log(results.matches[0]);
  console.log(standings.rows[0]);
  console.log(summary);
})();

API

getMatchResults(date, options)

  • date: YYYY-MM-DD 또는 Date
  • options.team: short name / full name / team code alias
  • options.seasonGrade: 기본값은 1 (KBL 1군)

getStandings()

  • 현재 KBL 팀 순위를 반환합니다.

getKBLSummary(date, options)

  • 날짜 결과와 현재 순위를 한 번에 반환합니다.

Notes

  • 공식 KBL JSON 엔드포인트 기준이라 HTML 크롤링보다 유지보수가 단순합니다.
  • match/listfromDate / toDateYYYYMMDD 형식으로 받습니다.
  • 1군 KBL 조회 기본값은 seasonGrade=1 입니다.