1. Go to this page and download the library: Download corbpie/nbalive library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
corbpie / nbalive example snippets
$this->url;//The final compiled URL used in the call
$this->response_code;//Returned HTTP response code
$this->response_size;//The size of the response
$this->connect_time;//Time it took to connect
$this->ip;//The IP of the API endpoint that was connected to
$this::CURRENT_SEASON;//Returns current season
$this::PREVIOUS_SEASON;//Returns previous season
$this::CURRENT_TYPE;//Returns current season type
//Mode types
$this::MODE_PER_GAME;
$this::MODE_TOTAL;
$this::MODE_PER48;
//Game types
$this::TYPE_REGULAR;
$this::TYPE_PLAY_IN;
$this::TYPE_PLAYOFFS;
$this::TYPE_ALL_STAR;
$this::TYPE_PRE_SEASON;
$today = new NBALive\NBAToday();
//Creates the arrays
$today->all_games;
$today->live_games;
$today->upcoming_games;
$today->completed_games;
//Format this data
$formatted = $today->gameFormatter($today->live_games);
$game_time = new NBALive\NBABase();
$game_time->secondsToFormattedGameTime(800);
$boxscore = new NBALive\NBABoxScore('0022301214');
//Or set game id with
$boxscore->game_id = "0022301214";
//Creates the arrays
$boxscore->home_team;
$boxscore->away_team;
$boxscore->home_players;
$boxscore->away_players;
$boxscore->sortAsc($boxscore->home_players, 'points');
$boxscore->sortDesc($boxscore->home_players, 'points');
//Get inactive players for both teams
$boxscore->getInactive();
$pbp = new NBALive\NBAPlayByPlay('0022301214');
//Or set game id with
$pbp->game_id = "0022301214";
//Creates the arrays
$pbp->all_plays;
$pbp->plays_count;
$pbp->last_10_plays;
//Player only plays
$pbp->playerOnly(202331);
//Team only plays
$pbp->teamOnly(1610612746);
//Get a score line/worm
$pbp->scoreLine();
$game_id = '0022300372';
$start_qtr = 1;
$end_qtr = 1;
$pbp_v3 = new NBALive\NBAPlayByPlayV3($game_id, $start_qtr, $end_qtr);
//Creates the arrays
$pbp_v3->all_plays;
$pbp_v3->plays_count;
$pbp_v3->last_10_plays;
//Player only plays
$pbp_v3->playerOnly(202331);
//Team only plays
$pbp_v3->teamOnly(1610612746);
//Scored only plays
$pbp_v3->scoredOnly();
//Get a score streaks for both teams
$pbp_v3->scoreStreaks();
$game_id = '0022300372';
$start_qtr = 1;
$end_qtr = 1;
$pbp_v2 = new NBALive\NBAPlayByPlayV2($game_id, $start_qtr, $end_qtr);
//Creates the arrays
$pbp_v2->all_plays;
$pbp_v2->plays_count;
$pbp_v2->last_10_plays;
//Player only plays
$pbp_v2->playerOnly(202331);
//Team only plays
$pbp_v2->teamOnly(1610612746);
//Scored only plays
$pbp_v2->scoredOnly();
$game_id = '0022300372';
$start_qtr = 1;
$end_qtr = 1;
$pbp_v1 = new NBALive\NBAPlayByPlayV1($game_id, $start_qtr, $end_qtr);
//Creates the arrays
$pbp_v1->all_plays;
$pbp_v1->plays_count;
$pbp_v1->last_10_plays;
//Scored only plays
$pbp_v1->scoredOnly();
$game_id = '0022300372';
$event_number = 89;
$play_clip = new NBALive\NBAPlayByPlayClips($game_id, $event_number);
//Creates the arrays
$play_clip->media;
$play_clip->details;
$bs = new NBALive\NBABoxScoreTraditional();
//Whole game
$bs->game_id = '0022300372';
$bs->fetch();
//Use true to only get home and visit players arrays and return early
$bs->fetch(true);
//Preset filter (Qtr 4)
$bs->game_id = '0022300372';
$bs->filter = $bs->buildQ4();//buildQ1(), buildQ2(), buildH1() etc.
$bs->fetch();
//Custom filter
$bs->game_id = '0022300372';
$bs->range_type = 1;
$bs->start_period = 4;
$bs->start_range = 0;
$bs->end_range = 28800;
$bs->end_period = 4;
$bs->filter = $bs->build();
$bs->fetch();
//Creates the arrays
$bs->teams;
$bs->teams_starters;
$bs->teams_bench;
$bs->home_team;
$bs->home_players;
$bs->home_starters;
$bs->home_bench;
$bs->away_team;
$bs->away_players;
$bs->away_starters;
$bs->away_bench;
$bs->sortAsc($bs->home_players, 'fieldGoalsAttempted');
$bs->sortDesc($bs->home_players, 'fieldGoalsMade');
$defensive = new NBALive\NBABoxScoreDefensive("0022301203");
//Or set game id with
$defensive->game_id = "0022301203";
//Creates the arrays
$defensive->home_players;
$defensive->away_players;
$matchups = new NBALive\NBABoxScoreMatchups("0022301203");
//Or set game id with
$matchups->game_id = "0022301203";
//Creates the arrays
$matchups->home_players;
$matchups->away_players;
//Get just a certain players matchups
$matchups->playerOnly(1629684);
//Get all matchups for a player
$matchups->playerMatchedWith(201935);
$lineups = new NBALive\NBATeamLineups();
$lineups->team_id = 1610612746;
$lineups->season = '2019-20';//Optional if NOT set will just be current season
$lineups->players_amount = 5;
$lineups->fetch();
//Creates the array
$lineups->details;
//Get lineups that contain a certain player only
$lineups->playerOnly(202695)
$team_shots = new NBALive\NBATeamDashPtShots();
$team_shots->team_id = 1610612746;
$team_shots->season = '2019-20';//Optional if NOT set will just be current season
$team_shots->fetch();
//Creates the arrays
$team_shots->general_shooting;
$team_shots->shot_clock_shooting;
$team_shots->dribble_shooting;
$team_shots->closest_defender_shooting;
$team_shots->closest_defender_10ft_shooting;
$team_shots->touch_time_shooting;
$rotations = new NBALive\NBARotations("0022301203");
//Or set game id with
$rotations->game_id = "0022301203";
//Creates the array
$pbp->details;
//Player only rotation
$pbp->playerOnly(202331);
//Team only rotation
$pbp->teamOnly(1610612746);
$team_yoy = new NBALive\NBATeamYearOverYear(1610612746);
//Creates the arrays
$team_yoy->details;
$team_yoy->latest;
$standings = new NBALive\NBAStandings('2023-24');
//Creates the arrays
$standings->standings;
$standings->east_standings;
$standings->west_standings;
$gl = new NBALive\NBALeagueGameLog();
//Creates the array
$gl->games;
$team = new NBALive\NBATeamInfo(1610612746);
//Creates the arrays
$team->info;
$team->ranks;
$team->seasons;
$logs = new NBALive\NBATeamGameLogs();
$logs->team_id = 1610612746;
$logs->season = '2023-24';//Optional
$logs->fetch();
//Creates the array
$logs->games;
//Last X games
$logs->lastXGames(10);//Last 10 games only
$players = new NBALive\NBAFranchisePlayers(1610612746);
//Creates the array
$players->players;
$schedule = new NBALive\NBASchedule('2023-12-20');
//Creates the array
$schedule->schedule;
//Get full season schedule for a team
$schedule->fullForTeam(1610612746);
//Get tomorrow's games
$tomorrow = (new DateTimeImmutable('tomorrow', new DateTimeZone('America/New_York')))->format('Y-m-d');
$schedule = new NBALive\NBASchedule($tomorrow);
//Get upcoming games for a team in next 7 days
$schedule->upcomingGames(1610612746, 7);
$hustle = new NBALive\NBABoxScoreHustle("0022301203");
//Or set game id with
$hustle->game_id = "0022301203";
//Creates these arrays
$hustle->home_players;
$hustle->away_team;
$hustle->home_team;
$hustle->away_team;
$sum = new NBALive\NBAGameSummary("0022301203");
//Or set game id with
$sum->game_id = "0022301203";
//Creates these arrays
$sum->home;
$sum->away;
$sum->refs;
$sum->inactive;
$sum->home_line_score;
$sum->away_line_score;
$sum->last_meeting;
$sum->statuses;
//Int
$sum->attendance;
$roster = new NBALive\NBARosters(1610612754, '2014-15');
//Creates the array
$roster->players;
$roster->coaches;
$yoy = new NBALive\NBAPlayerYearOverYear();
$yoy->player_id = 202331;//Required
$yoy->per_mode = 'PerGame';
//Set this if you want to get a specific season:
$yoy->season = '2019-20';
//Must run fetch()
$yoy->fetch();
//Creates the arrays
$yoy->details;
//For the specific season
$yoy->season_array;
$on_off = new NBALive\NBATeamPlayerOnOff();
$on_off->team_id = 1610612746;
$on_off->season = '2023-24';
//Must run fetch()
$yoy->fetch();
//Creates the arrays
$yoy->on;
$yoy->off;
//Get a specific player on and off
$on_off->player(201587);
//This build and returns:
$on_off->player_only;
$player = new NBALive\NBAPlayerShooting();
//Or set player id with
$player->player_id = 202331;
$player->season = '2019-20';
//Creates the arrays
$player->shot_5ft = [];
$player->shot_8ft = [];
$player->shot_area = [];
$player->assisted = [];
$player->shot_types_summary = [];
$player->shot_types = [];
$player->assisted_by = [];
$player = new NBALive\NBAPlayer(202331);
//Or set player id with
$player->player_id = 202331;
//Creates the arrays
$player->details;
$player->seasons;
$awards = new NBALive\NBAPlayerAwards(202331);
//Creates the array
$player->awards;
$awards = new NBALive\NBAPlayerCareer(202331, 'Totals');
//Creates the arrays
$player->season_totals_regular;
$player->career_totals_regular;
$player->season_totals_post;
$player->career_totals_post;
$player->season_totals_all_star;
$player->career_totals_all_star;
$player->season_totals_college;
$player->career_totals_college;
$player->season_totals_showcase;
$player->career_totals_showcase;
$player->season_rankings_regular;
$player->season_rankings_post;
$playoffs = new NBALive\NBAPlayoffPicture('22023');
$playoff_series = new NBALive\NBAPlayoffSeries('2023-24');
$team = new NBALive\NBATeam(1610612757);
//Or set team id with
$team->team_id = 1610612757;
//Creates the array
$team->details;
$teams = new NBALive\NBATeamYears();
//Creates the array
$teams->teams;
$match_ups = new NBALive\NBAMatchups();
$match_ups->season = '2023-24';
//Get only players from a team with
$match_ups->off_team_id = 1610612757;
//Get only certain player
$match_ups->off_player_id = 202331;
//Call fetch
$match_ups->fetch();
//Creates the array
$match_ups->details;
$shots = new NBALive\NBALeaguePlayerShotLocations();
$shots->season = '2023-24';
//Get only players from a team with
$shots->team_id = 1610612757;
//Choose location/range type
$shots->distance_range = 'By Zone';
$shots->distance_range = '5ft Range';
$shots->distance_range = '8ft Range';
//Creates the arrays depending on distance_range
$shots->zone;
$shots->range_5ft;
$shots->range_8ft;
$shots = new NBALive\NBALeaguePlayerShotPts();
$shots->season = '2023-24';
//Get only players from a team with
$shots->team_id = 1610612757;
//Creates the array
$shots->details;
$ve = new NBALive\NBAVideoEvents(1, '0022300568');
//Creates the array
$ve->details;