Skip to content

hoopR 3.0.0

Latest

Choose a tag to compare

@saiemgilani saiemgilani released this 26 Mar 14:45

HTTP Backend Migration

  • Breaking: Replaced httr with httr2 as the HTTP backend for all API requests across the package.
  • Removed httr from package dependencies (Imports).
  • request_with_proxy() now uses httr2 request/retry pipeline instead of rvest::session() with httr config arguments, resolving segfaults on systems with libcurl >= 8.x / curl R package >= 7.0.0.
  • All ESPN, NBA Stats, NBA G-League, NCAA, and KenPom HTTP calls now use shared internal helpers (.retry_request(), .resp_text()) backed by httr2.
  • check_status() now uses httr2::resp_status() instead of httr::status_code().
  • KenPom (kp_*) functions now use httr2 cookie jar authentication via login(), .kp_get_page(), and .kp_request() helpers.

Messaging Migration (usethis → cli)

  • Replaced all usethis::ui_*() messaging calls in database builder and loader functions with cli equivalents.
  • usethis::ui_stop()cli::cli_abort(), usethis::ui_oops()cli::cli_alert_danger(), usethis::ui_todo()cli::cli_ul(), usethis::ui_info()cli::cli_alert_info().
  • Inline markup converted: usethis::ui_value(){.val}, usethis::ui_path(){.file}, usethis::ui_code(){.code}.
  • Moved usethis from Imports to Suggests (retained for usethis::edit_r_environ() documentation references).

Social Branding (Twitter → X)

  • Updated all social media links and badges from Twitter to X across README, pkgdown site, and vignettes.
  • Shields.io badge logo=twitterlogo=x; profile URLs twitter.comx.com.
  • pkgdown navbar icon updated from fa-twitter to fa-x-twitter.

Stability and Test Robustness

  • Hardened API-facing tests against live schema drift and intermittent empty payloads.
  • Added explicit skip-on-empty guards for lineup and NCAA teams tests to avoid false negatives when upstream endpoints return no rows.
  • Updated expected columns for currently active payloads in key NBA endpoints (including nba_playercareerstats(), nba_playerdashptshotdefend(), and nba_playerprofilev2()).
  • Improved nba_playerprofilev2() assertions to validate core columns while tolerating empty optional result sets.

CI and Check Improvements

  • Added workflow-level concurrency and explicit permissions to GitHub Actions workflows.
  • Clarified optional environment variable usage in CI for live API test toggles.
  • Updated package build ignores to exclude local development folders from source checks.

NBA Play-by-Play V3

  • nba_playbyplayv3() function added — dedicated wrapper for the NBA Stats PlayByPlayV3 endpoint.
  • nba_pbp() and nba_pbps() now default to version = "v3" (previously "v2"). Pass version = "v2" to use the previous behavior.
  • .v3_to_v2_format() internal helper added — converts V3 play-by-play data to V2-compatible column format with mapped event types, player resolution, and retained V3 shot coordinate columns (x_legacy, y_legacy, shot_distance, shot_result, is_field_goal, points_total, shot_value).
  • .build_player_roster() internal helper added — retrieves player roster from nba_boxscoretraditionalv3() for name-to-ID resolution during V3-to-V2 conversion.
  • .players_on_court_v3() internal helper rewritten — now uses nba_gamerotation() stint data with interval mapping for robust on-court player determination (replaces previous substitution-parsing approach).
  • nba_pbp() p parameter is now optional (default: NULL) — previously required even when not using progress tracking.
  • Removed stringr::str_match import from NAMESPACE — V3 clock parsing now uses base R regex functions.

NBA Boxscore Summary V3

  • nba_boxscoresummaryv3() function added — returns a named list of 9 data frames: GameSummary, GameInfo, ArenaInfo, Officials, LineScore, InactivePlayers, LastFiveMeetings, OtherStats, AvailableVideo.

New NBA Stats API Endpoint Wrappers

  • nba_commonteamyears() function added — returns team IDs with their active year ranges.
  • nba_dunkscoreleaders() function added — returns dunk tracking data with biomechanics, scores, and style metrics.
  • nba_gravityleaders() function added — returns gravity scores measuring how much defensive attention each player draws.
  • nba_iststandings() function added — returns In-Season Tournament (NBA Cup) standings.
  • nba_scheduleleaguev2int() function added — returns international schedule data with broadcaster information.
  • nba_teamandplayersvsplayers() function added — returns team and player lineup comparison stats (5 datasets).
  • nba_videoeventsasset() function added — returns video event asset data for a given game event.

ESPN & G-League Functions

  • espn_nba_team_current_roster() function added — returns current team roster from ESPN.
  • espn_mbb_team_current_roster() function added — returns current MBB team roster from ESPN.
  • nbagl_live_pbp() function added — returns live G-League play-by-play data.
  • nbagl_live_boxscore() function added — returns live G-League box score data.

Other Improvements

  • Internal nba_endpoint() registry updated with all V3 boxscore endpoints and boxscoresummaryv3.
  • Removed deprecated qs dependency.
  • Updated GitHub Actions to v4.
  • Cleaned up .Rbuildignore duplicates.
  • Added comprehensive CONTRIBUTING.md with naming conventions and test environment documentation.
  • Moved furrr and future dependencies to Suggests with version requirements for users who want to use parallel features, but not required for core functionality.
  • Add lifecycle dependency and deprecation warnings for unstable functions/endpoints to guide users to maintained alternatives.

Bug Fixes

  • Fixed df_list not initialized before tryCatch in 147 NBA Stats API wrapper functions, preventing crashes on API errors.
  • Fixed nba_data_pbp() plays_df not initialized before tryCatch.
  • Fixed helper-skip.R test guard functions to use proper string comparison (!= "1") instead of numeric comparison (== 0).
  • Fixed nba_dunkscoreleaders() HTTP 400 error caused by empty string parameters.
  • Fixed V3-style data.frame parsing for leader/standings endpoints.
  • Fixed nba_iststandings() nested games column flattening.
  • Fixed %||% import for R < 4.4.0 compatibility.
  • Fixed data not initialized before tryCatch in nba_playbyplayv3() and nba_pbp(), preventing crashes on API errors.
  • Fixed nbagl_pbp() to avoid on-court enrichment dependency failures for G-League game IDs by using the stable core play-by-play path.
  • Fixed NBAGL wrapper defaults for error paths where return objects were not initialized before tryCatch.

Deprecations

  • Deprecated nba_boxscorefourfactorsv2() in favor of nba_boxscorefourfactorsv3() due to unstable/partial V2 API responses.
  • Deprecated nba_boxscoremiscv2() in favor of nba_boxscoremiscv3() due to unstable/partial V2 API responses.
  • Deprecated nba_boxscorescoringv2() in favor of nba_boxscorescoringv3() due to unstable/partial V2 API responses.
  • Deprecated nba_boxscoreusagev2() in favor of nba_boxscoreusagev3() due to unstable/partial V2 API responses.
  • Deprecated nba_boxscoreplayertrackv2() in favor of nba_boxscoreplayertrackv3() due to unstable/partial V2 API responses.
  • Deprecated nba_boxscorehustlev2() in favor of nba_hustlestatsboxscore() due to unstable/partial V2 API responses.
  • Deprecated nba_homepageleaders() in favor of nba_leagueleaders() due to unstable/empty endpoint responses.
  • Deprecated nba_homepagev2() in favor of nba_leagueleaders() due to unstable/empty endpoint responses.
  • Deprecated nba_leaderstiles() in favor of nba_leagueleaders() due to unstable/empty endpoint responses.
  • Deprecated nba_teamgamestreakfinder() in favor of nba_teamgamelogs() due to unstable/empty endpoint responses.
  • Deprecated nba_teamhistoricalleaders() in favor of nba_franchiseleaders() due to unstable/empty endpoint responses.
  • Deprecated nba_videodetails() in favor of nba_videodetailsasset() due to unstable/empty endpoint responses.
  • Deprecated nba_winprobabilitypbp() in favor of nba_playbyplayv3() due to unstable/empty endpoint responses.
  • Deprecated nba_playercareerbycollege() in favor of nba_playercareerbycollegerollup()/nba_leaguedashplayerbiostats() due to unstable/empty endpoint responses.
  • Deprecated nba_playernextngames() in favor of nba_playerprofilev2() due to unstable/empty endpoint responses.
  • Deprecated nba_scoreboard() in favor of nba_scoreboardv3() due to unstable/empty endpoint responses.
  • Deprecated nba_scoreboardv2() in favor of nba_scoreboardv3() due to unstable/partial endpoint responses.

Test Improvements

  • Converted 400+ expect_equal(colnames()) assertions to expect_in() for subset validation, preventing test failures when APIs add new columns.
  • Added tests for all new endpoints with column validation and rate limiting.
  • Added skip_ncaa_mbb_test() and skip_ncaa_wbb_test() helpers.
  • Updated ESPN test expectations for current API responses.
  • Updated NBAGL tests to validate NBA Stats-backed return shapes (nbagl_players() and nbagl_standings() named-list returns, and current schedule/PBP core columns).