Skip to content

Latest commit

 

History

History
32 lines (25 loc) · 1.38 KB

File metadata and controls

32 lines (25 loc) · 1.38 KB

bls-cli

Unofficial CLI + TypeScript client for the BLS API v2 (Bureau of Labor Statistics).

Build & Test

npm run build        # tsc -> dist/
npm test             # unit tests (mocked HTTP)
npm run test:integration  # live API tests (needs BLS_API_KEY)
npm run dev -- <args>     # run CLI directly via tsx

Architecture

  • src/api/client.tsBlsClient class, uses native fetch, POST requests for timeseries data
  • src/api/types.ts — all TypeScript types for BLS API requests/responses
  • src/api/shortcuts.ts — well-known series ID mappings (cpi, unemployment, jobs)
  • src/cli.ts — CLI entry point, routes commands to handlers
  • src/commands/ — one file per command group (series, popular, surveys, shortcuts)
  • src/cli/ — parseArgs configs, formatters (json/csv/table), help text
  • src/tests/ — node:test runner, fixtures in tests/fixtures/

Conventions

  • Zero runtime dependencies (Node 18+ native fetch, parseArgs, test runner)
  • ESM ("type": "module") with .js import extensions
  • BLS API uses POST with JSON body for timeseries data, GET for surveys/popular
  • CLI flags use kebab-case, API params use camelCase in request body
  • JSON output includes _truncated and _next_offset when results are paginated
  • Tests mock global.fetch — no external mock libraries
  • Mock tests verify POST method, Content-Type header, and request body