Ejemplo n.º 1
0
 def __init__(self,
              team_id,
              league_id=LeagueID.default,
              season_nullable=SeasonNullable.default,
              season_type_nullable=SeasonTypeNullable.default):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'TeamID': team_id,
             'LeagueID': league_id,
             'Season': season_nullable,
             'SeasonType': season_type_nullable
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [
         Endpoint.DataSet(data=data_set)
         for data_set_name, data_set in data_sets.items()
     ]
     self.available_seasons = Endpoint.DataSet(
         data=data_sets['AvailableSeasons'])
     self.team_info_common = Endpoint.DataSet(
         data=data_sets['TeamInfoCommon'])
     self.team_season_ranks = Endpoint.DataSet(
         data=data_sets['TeamSeasonRanks'])
Ejemplo n.º 2
0
 def __init__(self,
              league_id=LeagueID.default,
              per_mode48=PerMode48.default,
              scope=Scope.default,
              season_all_time=SeasonAll_Time.default,
              season_type_all_star=SeasonTypeAllStar.default,
              stat_category_abbreviation=StatCategoryAbbreviation.default,
              active_flag_nullable=''):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'LeagueID': league_id,
             'PerMode': per_mode48,
             'Scope': scope,
             'Season': season_all_time,
             'SeasonType': season_type_all_star,
             'StatCategory': stat_category_abbreviation,
             'ActiveFlag': active_flag_nullable
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [
         Endpoint.DataSet(data=data_set)
         for data_set_name, data_set in data_sets.items()
     ]
     self.league_leaders = Endpoint.DataSet(data=data_sets['LeagueLeaders'])
Ejemplo n.º 3
0
 def __init__(self,
              day_offset=DayOffset.default,
              game_date=GameDate.default,
              league_id=LeagueID.default):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'DayOffset': day_offset,
             'GameDate': game_date,
             'LeagueID': league_id
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [
         Endpoint.DataSet(data=data_set)
         for data_set_name, data_set in data_sets.items()
     ]
     self.available = Endpoint.DataSet(data=data_sets['Available'])
     self.east_conf_standings_by_day = Endpoint.DataSet(
         data=data_sets['EastConfStandingsByDay'])
     self.game_header = Endpoint.DataSet(data=data_sets['GameHeader'])
     self.last_meeting = Endpoint.DataSet(data=data_sets['LastMeeting'])
     self.line_score = Endpoint.DataSet(data=data_sets['LineScore'])
     self.series_standings = Endpoint.DataSet(
         data=data_sets['SeriesStandings'])
     self.team_leaders = Endpoint.DataSet(data=data_sets['TeamLeaders'])
     self.ticket_links = Endpoint.DataSet(data=data_sets['TicketLinks'])
     self.west_conf_standings_by_day = Endpoint.DataSet(
         data=data_sets['WestConfStandingsByDay'])
     self.win_probability = Endpoint.DataSet(
         data=data_sets['WinProbability'])
Ejemplo n.º 4
0
 def __init__(self,
              player_id,
              measure_type_base=MeasureTypeBase.default,
              pace_adjust_no=PaceAdjustNo.default,
              per_mode36=PerMode36.default,
              plus_minus_no=PlusMinusNo.default,
              rank_no=RankNo.default,
              season=Season.default,
              season_type_playoffs=SeasonType.default,
              league_id_nullable=LeagueIDNullable.default):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'PlayerID': player_id,
             'MeasureType': measure_type_base,
             'PaceAdjust': pace_adjust_no,
             'PerMode': per_mode36,
             'PlusMinus': plus_minus_no,
             'Rank': rank_no,
             'Season': season,
             'SeasonType': season_type_playoffs,
             'LeagueID': league_id_nullable
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [
         Endpoint.DataSet(data=data_set)
         for data_set_name, data_set in data_sets.items()
     ]
     self.days_rest_modified = Endpoint.DataSet(
         data=data_sets['DaysRestModified'])
     self.last_n_games = Endpoint.DataSet(data=data_sets['LastNGames'])
     self.location = Endpoint.DataSet(data=data_sets['Location'])
     self.opponent = Endpoint.DataSet(data=data_sets['Opponent'])
     self.overall = Endpoint.DataSet(data=data_sets['Overall'])
Ejemplo n.º 5
0
 def __init__(self,
              league_id=LeagueID.default,
              college_nullable='',
              overall_pick_nullable='',
              round_num_nullable='',
              round_pick_nullable='',
              season_year_nullable=SeasonYearNullable.default,
              team_id_nullable='',
              topx_nullable=''):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'LeagueID': league_id,
             'College': college_nullable,
             'OverallPick': overall_pick_nullable,
             'RoundNum': round_num_nullable,
             'RoundPick': round_pick_nullable,
             'Season': season_year_nullable,
             'TeamID': team_id_nullable,
             'TopX': topx_nullable
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [
         Endpoint.DataSet(data=data_set)
         for data_set_name, data_set in data_sets.items()
     ]
     self.draft_history = Endpoint.DataSet(data=data_sets['DraftHistory'])
Ejemplo n.º 6
0
 def __init__(self,
              vs_player_id_list,
              player_id_list,
              last_n_games=LastNGames.default,
              measure_type_detailed_defense=MeasureTypeDetailedDefense.default,
              month=Month.default,
              opponent_team_id=0,
              pace_adjust=PaceAdjust.default,
              per_mode_detailed=PerModeDetailed.default,
              period=Period.default,
              plus_minus=PlusMinus.default,
              rank=Rank.default,
              season=Season.default,
              season_type_playoffs=SeasonType.default,
              conference_nullable=ConferenceNullable.default,
              date_from_nullable='',
              date_to_nullable='',
              division_simple_nullable=DivisionSimpleNullable.default,
              game_segment_nullable=GameSegmentNullable.default,
              league_id_nullable=LeagueIDNullable.default,
              location_nullable=LocationNullable.default,
              outcome_nullable=OutcomeNullable.default,
              season_segment_nullable=SeasonSegmentNullable.default,
              shot_clock_range_nullable=ShotClockRangeNullable.default,
              vs_conference_nullable=ConferenceNullable.default,
              vs_division_nullable=DivisionNullable.default):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'VsPlayerIDList': vs_player_id_list,
             'PlayerIDList': player_id_list,
             'LastNGames': last_n_games,
             'MeasureType': measure_type_detailed_defense,
             'Month': month,
             'OpponentTeamID': opponent_team_id,
             'PaceAdjust': pace_adjust,
             'PerMode': per_mode_detailed,
             'Period': period,
             'PlusMinus': plus_minus,
             'Rank': rank,
             'Season': season,
             'SeasonType': season_type_playoffs,
             'Conference': conference_nullable,
             'DateFrom': date_from_nullable,
             'DateTo': date_to_nullable,
             'Division': division_simple_nullable,
             'GameSegment': game_segment_nullable,
             'LeagueID': league_id_nullable,
             'Location': location_nullable,
             'Outcome': outcome_nullable,
             'SeasonSegment': season_segment_nullable,
             'ShotClockRange': shot_clock_range_nullable,
             'VsConference': vs_conference_nullable,
             'VsDivision': vs_division_nullable
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [Endpoint.DataSet(data=data_set) for data_set_name, data_set in data_sets.items()]
     self.individual = Endpoint.DataSet(data=data_sets['Individual'])
     self.overall_compare = Endpoint.DataSet(data=data_sets['OverallCompare'])
Ejemplo n.º 7
0
 def __init__(self,
              game_scope_detailed=GameScopeDetailed.default,
              league_id=LeagueID.default,
              player_or_team=PlayerOrTeam.default,
              player_scope=PlayerScope.default,
              season=Season.default,
              season_type_playoffs=SeasonType.default,
              stat=Stat.default):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'GameScope': game_scope_detailed,
             'LeagueID': league_id,
             'PlayerOrTeam': player_or_team,
             'PlayerScope': player_scope,
             'Season': season,
             'SeasonType': season_type_playoffs,
             'Stat': stat
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [
         Endpoint.DataSet(data=data_set)
         for data_set_name, data_set in data_sets.items()
     ]
     self.all_time_season_high = Endpoint.DataSet(
         data=data_sets['AllTimeSeasonHigh'])
     self.last_season_high = Endpoint.DataSet(
         data=data_sets['LastSeasonHigh'])
     self.leaders_tiles = Endpoint.DataSet(data=data_sets['LeadersTiles'])
     self.low_season_high = Endpoint.DataSet(
         data=data_sets['LowSeasonHigh'])
Ejemplo n.º 8
0
 def __init__(self,
              game_id,
              end_period=EndPeriod.default,
              end_range=EndRange.default,
              range_type=RangeType.default,
              start_period=StartPeriod.default,
              start_range=StartRange.default):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'GameID': game_id,
             'EndPeriod': end_period,
             'EndRange': end_range,
             'RangeType': range_type,
             'StartPeriod': start_period,
             'StartRange': start_range
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [
         Endpoint.DataSet(data=data_set)
         for data_set_name, data_set in data_sets.items()
     ]
     self.player_stats = Endpoint.DataSet(data=data_sets['PlayerStats'])
     self.team_starter_bench_stats = Endpoint.DataSet(
         data=data_sets['TeamStarterBenchStats'])
     self.team_stats = Endpoint.DataSet(data=data_sets['TeamStats'])
Ejemplo n.º 9
0
 def __init__(self,
              game_scope_detailed=GameScopeDetailed.default,
              league_id=LeagueID.default,
              player_or_team=PlayerOrTeam.default,
              player_scope=PlayerScope.default,
              season=Season.default,
              season_type_playoffs=SeasonType.default,
              stat_category=StatCategory.default):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'GameScope': game_scope_detailed,
             'LeagueID': league_id,
             'PlayerOrTeam': player_or_team,
             'PlayerScope': player_scope,
             'Season': season,
             'SeasonType': season_type_playoffs,
             'StatCategory': stat_category
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [
         Endpoint.DataSet(data=data_set)
         for data_set_name, data_set in data_sets.items()
     ]
     self.home_page_leaders = Endpoint.DataSet(
         data=data_sets['HomePageLeaders'])
     self.league_average = Endpoint.DataSet(data=data_sets['LeagueAverage'])
     self.league_max = Endpoint.DataSet(data=data_sets['LeagueMax'])
Ejemplo n.º 10
0
 def __init__(self,
              team_id,
              player_id,
              last_n_games=LastNGames.default,
              league_id=LeagueID.default,
              month=Month.default,
              opponent_team_id=0,
              per_mode_simple=PerModeSimple.default,
              period=Period.default,
              season=Season.default,
              season_type_all_star=SeasonTypeAllStar.default,
              date_from_nullable='',
              date_to_nullable='',
              game_segment_nullable=GameSegmentNullable.default,
              location_nullable=LocationNullable.default,
              outcome_nullable=OutcomeNullable.default,
              season_segment_nullable=SeasonSegmentNullable.default,
              vs_conference_nullable=ConferenceNullable.default,
              vs_division_nullable=DivisionNullable.default):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'TeamID': team_id,
             'PlayerID': player_id,
             'LastNGames': last_n_games,
             'LeagueID': league_id,
             'Month': month,
             'OpponentTeamID': opponent_team_id,
             'PerMode': per_mode_simple,
             'Period': period,
             'Season': season,
             'SeasonType': season_type_all_star,
             'DateFrom': date_from_nullable,
             'DateTo': date_to_nullable,
             'GameSegment': game_segment_nullable,
             'Location': location_nullable,
             'Outcome': outcome_nullable,
             'SeasonSegment': season_segment_nullable,
             'VsConference': vs_conference_nullable,
             'VsDivision': vs_division_nullable
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [
         Endpoint.DataSet(data=data_set)
         for data_set_name, data_set in data_sets.items()
     ]
     self.closest_defender10ft_plus_shooting = Endpoint.DataSet(
         data=data_sets['ClosestDefender10ftPlusShooting'])
     self.closest_defender_shooting = Endpoint.DataSet(
         data=data_sets['ClosestDefenderShooting'])
     self.dribble_shooting = Endpoint.DataSet(
         data=data_sets['DribbleShooting'])
     self.general_shooting = Endpoint.DataSet(
         data=data_sets['GeneralShooting'])
     self.overall = Endpoint.DataSet(data=data_sets['Overall'])
     self.shot_clock_shooting = Endpoint.DataSet(
         data=data_sets['ShotClockShooting'])
     self.touch_time_shooting = Endpoint.DataSet(
         data=data_sets['TouchTimeShooting'])
Ejemplo n.º 11
0
def required_parameters_test(endpoint):
    status = 'success'
    nba_stats_response = NBAStatsHTTP().send_api_request(endpoint=endpoint,
                                                         parameters={})

    required_parameters = get_required_parameters(endpoint, nba_stats_response)

    if '<title>NBA.com/Stats  | 404 Page Not Found </title>' in nba_stats_response.get_response(
    ):
        status = 'deprecated'
        return status, None, None, None

    required_params = {}
    required_params_errors = {}
    for prop in required_parameters:
        if prop in parameter_map:
            if len(parameter_map[prop]['non-nullable']):
                map_key = 'non-nullable'
            else:
                map_key = 'nullable'
            parameter_info_key = list(parameter_map[prop][map_key].values())[0]
            parameter_info = parameter_variations[parameter_info_key]
            required_params[prop] = parameter_info['parameter_value']
            required_params_errors[prop] = parameter_info[
                'parameter_error_value']
        else:
            print('Property "{prop}" not in parameter_map'.format(prop=prop))
            status = 'invalid'
            required_params[prop] = '0'
            required_params_errors[prop] = 'a'

    return status, required_parameters, required_params, required_params_errors
Ejemplo n.º 12
0
 def __init__(
         self,
         team_id,
         last_n_games=LastNGames.default,
         measure_type_detailed_defense=MeasureTypeDetailedDefense.default,
         month=Month.default,
         opponent_team_id=0,
         pace_adjust=PaceAdjust.default,
         per_mode_detailed=PerModeDetailed.default,
         period=Period.default,
         plus_minus=PlusMinus.default,
         rank=Rank.default,
         season=Season.default,
         season_type_all_star=SeasonTypeAllStar.default,
         date_from_nullable='',
         date_to_nullable='',
         game_segment_nullable=GameSegmentNullable.default,
         league_id_nullable=LeagueIDNullable.default,
         location_nullable=LocationNullable.default,
         outcome_nullable=OutcomeNullable.default,
         season_segment_nullable=SeasonSegmentNullable.default,
         vs_conference_nullable=ConferenceNullable.default,
         vs_division_nullable=DivisionNullable.default):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'TeamID': team_id,
             'LastNGames': last_n_games,
             'MeasureType': measure_type_detailed_defense,
             'Month': month,
             'OpponentTeamID': opponent_team_id,
             'PaceAdjust': pace_adjust,
             'PerMode': per_mode_detailed,
             'Period': period,
             'PlusMinus': plus_minus,
             'Rank': rank,
             'Season': season,
             'SeasonType': season_type_all_star,
             'DateFrom': date_from_nullable,
             'DateTo': date_to_nullable,
             'GameSegment': game_segment_nullable,
             'LeagueID': league_id_nullable,
             'Location': location_nullable,
             'Outcome': outcome_nullable,
             'SeasonSegment': season_segment_nullable,
             'VsConference': vs_conference_nullable,
             'VsDivision': vs_division_nullable
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [
         Endpoint.DataSet(data=data_set)
         for data_set_name, data_set in data_sets.items()
     ]
     self.overall_team_player_on_off_details = Endpoint.DataSet(
         data=data_sets['OverallTeamPlayerOnOffDetails'])
     self.players_off_court_team_player_on_off_details = Endpoint.DataSet(
         data=data_sets['PlayersOffCourtTeamPlayerOnOffDetails'])
     self.players_on_court_team_player_on_off_details = Endpoint.DataSet(
         data=data_sets['PlayersOnCourtTeamPlayerOnOffDetails'])
Ejemplo n.º 13
0
 def __init__(self,
              player_id,
              season_all=SeasonAll.default,
              season_type_all_star=SeasonTypeAllStar.default,
              date_from_nullable='',
              date_to_nullable='',
              league_id_nullable=LeagueIDNullable.default):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'PlayerID': player_id,
             'Season': season_all,
             'SeasonType': season_type_all_star,
             'DateFrom': date_from_nullable,
             'DateTo': date_to_nullable,
             'LeagueID': league_id_nullable
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [
         Endpoint.DataSet(data=data_set)
         for data_set_name, data_set in data_sets.items()
     ]
     self.player_game_log = Endpoint.DataSet(
         data=data_sets['PlayerGameLog'])
Ejemplo n.º 14
0
 def __init__(self,
              player_id,
              per_mode36=PerMode36.default,
              league_id_nullable=LeagueIDNullable.default):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'PlayerID': player_id,
             'PerMode': per_mode36,
             'LeagueID': league_id_nullable
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [Endpoint.DataSet(data=data_set) for data_set_name, data_set in data_sets.items()]
     self.career_highs = Endpoint.DataSet(data=data_sets['CareerHighs'])
     self.career_totals_all_star_season = Endpoint.DataSet(data=data_sets['CareerTotalsAllStarSeason'])
     self.career_totals_college_season = Endpoint.DataSet(data=data_sets['CareerTotalsCollegeSeason'])
     self.career_totals_post_season = Endpoint.DataSet(data=data_sets['CareerTotalsPostSeason'])
     self.career_totals_preseason = Endpoint.DataSet(data=data_sets['CareerTotalsPreseason'])
     self.career_totals_regular_season = Endpoint.DataSet(data=data_sets['CareerTotalsRegularSeason'])
     self.next_game = Endpoint.DataSet(data=data_sets['NextGame'])
     self.season_highs = Endpoint.DataSet(data=data_sets['SeasonHighs'])
     self.season_rankings_post_season = Endpoint.DataSet(data=data_sets['SeasonRankingsPostSeason'])
     self.season_rankings_regular_season = Endpoint.DataSet(data=data_sets['SeasonRankingsRegularSeason'])
     self.season_totals_all_star_season = Endpoint.DataSet(data=data_sets['SeasonTotalsAllStarSeason'])
     self.season_totals_college_season = Endpoint.DataSet(data=data_sets['SeasonTotalsCollegeSeason'])
     self.season_totals_post_season = Endpoint.DataSet(data=data_sets['SeasonTotalsPostSeason'])
     self.season_totals_preseason = Endpoint.DataSet(data=data_sets['SeasonTotalsPreseason'])
     self.season_totals_regular_season = Endpoint.DataSet(data=data_sets['SeasonTotalsRegularSeason'])
Ejemplo n.º 15
0
 def __init__(self,
              counter=0,
              direction=Direction.default,
              league_id=LeagueID.default,
              player_or_team_abbreviation=PlayerOrTeamAbbreviation.default,
              season_all_time=SeasonAllTime.default,
              season_type_all_star=SeasonTypeAllStar.default,
              sorter=Sorter.default,
              date_from_nullable='',
              date_to_nullable=''):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'Counter': counter,
             'Direction': direction,
             'LeagueID': league_id,
             'PlayerOrTeam': player_or_team_abbreviation,
             'Season': season_all_time,
             'SeasonType': season_type_all_star,
             'Sorter': sorter,
             'DateFrom': date_from_nullable,
             'DateTo': date_to_nullable
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [
         Endpoint.DataSet(data=data_set)
         for data_set_name, data_set in data_sets.items()
     ]
     self.league_game_log = Endpoint.DataSet(
         data=data_sets['LeagueGameLog'])
 def __init__(self,
              team_id,
              last_n_games=LastNGames.default,
              measure_type_detailed_defense=MeasureTypeDetailedDefense.default,
              month=Month.default,
              opponent_team_id=0,
              pace_adjust=PaceAdjust.default,
              per_mode_detailed=PerModeDetailed.default,
              period=Period.default,
              plus_minus=PlusMinus.default,
              rank=Rank.default,
              season=Season.default,
              season_type_all_star=SeasonTypeAllStar.default,
              date_from_nullable='',
              date_to_nullable='',
              game_segment_nullable=GameSegmentNullable.default,
              league_id_nullable=LeagueIDNullable.default,
              location_nullable=LocationNullable.default,
              outcome_nullable=OutcomeNullable.default,
              po_round_nullable='',
              season_segment_nullable=SeasonSegmentNullable.default,
              shot_clock_range_nullable=ShotClockRangeNullable.default,
              vs_conference_nullable=ConferenceNullable.default,
              vs_division_nullable=DivisionNullable.default):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'TeamID': team_id,
             'LastNGames': last_n_games,
             'MeasureType': measure_type_detailed_defense,
             'Month': month,
             'OpponentTeamID': opponent_team_id,
             'PaceAdjust': pace_adjust,
             'PerMode': per_mode_detailed,
             'Period': period,
             'PlusMinus': plus_minus,
             'Rank': rank,
             'Season': season,
             'SeasonType': season_type_all_star,
             'DateFrom': date_from_nullable,
             'DateTo': date_to_nullable,
             'GameSegment': game_segment_nullable,
             'LeagueID': league_id_nullable,
             'Location': location_nullable,
             'Outcome': outcome_nullable,
             'PORound': po_round_nullable,
             'SeasonSegment': season_segment_nullable,
             'ShotClockRange': shot_clock_range_nullable,
             'VsConference': vs_conference_nullable,
             'VsDivision': vs_division_nullable
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [Endpoint.DataSet(data=data_set) for data_set_name, data_set in data_sets.items()]
     self.by_actual_margin_team_dashboard = Endpoint.DataSet(data=data_sets['ByActualMarginTeamDashboard'])
     self.by_half_team_dashboard = Endpoint.DataSet(data=data_sets['ByHalfTeamDashboard'])
     self.by_period_team_dashboard = Endpoint.DataSet(data=data_sets['ByPeriodTeamDashboard'])
     self.by_score_margin_team_dashboard = Endpoint.DataSet(data=data_sets['ByScoreMarginTeamDashboard'])
     self.overall_team_dashboard = Endpoint.DataSet(data=data_sets['OverallTeamDashboard'])
Ejemplo n.º 17
0
 def __init__(self,
              team_id,
              player_id,
              last_n_games=LastNGames.default,
              league_id=LeagueID.default,
              month=Month.default,
              opponent_team_id=0,
              per_mode_simple=PerModeSimple.default,
              period=Period.default,
              season=Season.default,
              season_type_all_star=SeasonTypeAllStar.default,
              date_from_nullable='',
              date_to_nullable='',
              game_segment_nullable=GameSegmentNullable.default,
              location_nullable=LocationNullable.default,
              outcome_nullable=OutcomeNullable.default,
              season_segment_nullable=SeasonSegmentNullable.default,
              vs_conference_nullable=ConferenceNullable.default,
              vs_division_nullable=DivisionNullable.default):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'TeamID': team_id,
             'PlayerID': player_id,
             'LastNGames': last_n_games,
             'LeagueID': league_id,
             'Month': month,
             'OpponentTeamID': opponent_team_id,
             'PerMode': per_mode_simple,
             'Period': period,
             'Season': season,
             'SeasonType': season_type_all_star,
             'DateFrom': date_from_nullable,
             'DateTo': date_to_nullable,
             'GameSegment': game_segment_nullable,
             'Location': location_nullable,
             'Outcome': outcome_nullable,
             'SeasonSegment': season_segment_nullable,
             'VsConference': vs_conference_nullable,
             'VsDivision': vs_division_nullable
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [
         Endpoint.DataSet(data=data_set)
         for data_set_name, data_set in data_sets.items()
     ]
     self.num_contested_rebounding = Endpoint.DataSet(
         data=data_sets['NumContestedRebounding'])
     self.overall_rebounding = Endpoint.DataSet(
         data=data_sets['OverallRebounding'])
     self.reb_distance_rebounding = Endpoint.DataSet(
         data=data_sets['RebDistanceRebounding'])
     self.shot_distance_rebounding = Endpoint.DataSet(
         data=data_sets['ShotDistanceRebounding'])
     self.shot_type_rebounding = Endpoint.DataSet(
         data=data_sets['ShotTypeRebounding'])
Ejemplo n.º 18
0
 def get_request(self):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters=self.parameters,
         proxy=self.proxy,
         headers=self.headers,
         timeout=self.timeout,
     )
     self.load_response()
Ejemplo n.º 19
0
 def __init__(self,
              defense_category=DefenseCategory.default,
              league_id=LeagueID.default,
              per_mode_simple=PerModeSimple.default,
              season=Season.default,
              season_type_all_star=SeasonTypeAllStar.default,
              conference_nullable=ConferenceNullable.default,
              date_from_nullable='',
              date_to_nullable='',
              division_nullable=DivisionNullable.default,
              game_segment_nullable=GameSegmentNullable.default,
              last_n_games_nullable=LastNGamesNullable.default,
              location_nullable=LocationNullable.default,
              month_nullable=MonthNullable.default,
              opponent_team_id_nullable='',
              outcome_nullable=OutcomeNullable.default,
              po_round_nullable='',
              period_nullable=PeriodNullable.default,
              season_segment_nullable=SeasonSegmentNullable.default,
              team_id_nullable='',
              vs_conference_nullable=ConferenceNullable.default,
              vs_division_nullable=DivisionNullable.default):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'DefenseCategory': defense_category,
             'LeagueID': league_id,
             'PerMode': per_mode_simple,
             'Season': season,
             'SeasonType': season_type_all_star,
             'Conference': conference_nullable,
             'DateFrom': date_from_nullable,
             'DateTo': date_to_nullable,
             'Division': division_nullable,
             'GameSegment': game_segment_nullable,
             'LastNGames': last_n_games_nullable,
             'Location': location_nullable,
             'Month': month_nullable,
             'OpponentTeamID': opponent_team_id_nullable,
             'Outcome': outcome_nullable,
             'PORound': po_round_nullable,
             'Period': period_nullable,
             'SeasonSegment': season_segment_nullable,
             'TeamID': team_id_nullable,
             'VsConference': vs_conference_nullable,
             'VsDivision': vs_division_nullable
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [
         Endpoint.DataSet(data=data_set)
         for data_set_name, data_set in data_sets.items()
     ]
     self.league_dash_pt_team_defend = Endpoint.DataSet(
         data=data_sets['LeagueDashPtTeamDefend'])
Ejemplo n.º 20
0
 def __init__(self,
              context_measure_detailed=ContextMeasureDetailed.default,
              group_id=0,
              league_id=LeagueID.default,
              period=Period.default,
              season=Season.default,
              season_type_all_star=SeasonTypeAllStar.default,
              context_filter_nullable='',
              date_from_nullable='',
              date_to_nullable='',
              game_id_nullable='',
              game_segment_nullable=GameSegmentNullable.default,
              last_n_games_nullable=LastNGamesNullable.default,
              location_nullable=LocationNullable.default,
              month_nullable=MonthNullable.default,
              opponent_team_id_nullable='',
              outcome_nullable=OutcomeNullable.default,
              season_segment_nullable=SeasonSegmentNullable.default,
              team_id_nullable='',
              vs_conference_nullable=ConferenceNullable.default,
              vs_division_nullable=DivisionNullable.default):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'ContextMeasure': context_measure_detailed,
             'GROUP_ID': group_id,
             'LeagueID': league_id,
             'Period': period,
             'Season': season,
             'SeasonType': season_type_all_star,
             'ContextFilter': context_filter_nullable,
             'DateFrom': date_from_nullable,
             'DateTo': date_to_nullable,
             'GameID': game_id_nullable,
             'GameSegment': game_segment_nullable,
             'LastNGames': last_n_games_nullable,
             'Location': location_nullable,
             'Month': month_nullable,
             'OpponentTeamID': opponent_team_id_nullable,
             'Outcome': outcome_nullable,
             'SeasonSegment': season_segment_nullable,
             'TeamID': team_id_nullable,
             'VsConference': vs_conference_nullable,
             'VsDivision': vs_division_nullable
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [
         Endpoint.DataSet(data=data_set)
         for data_set_name, data_set in data_sets.items()
     ]
     self.shot_chart_lineup_detail = Endpoint.DataSet(
         data=data_sets['ShotChartLineupDetail'])
     self.shot_chart_lineup_league_average = Endpoint.DataSet(
         data=data_sets['ShotChartLineupLeagueAverage'])
Ejemplo n.º 21
0
 def __init__(self, league_id=LeagueID.default):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={'LeagueID': league_id},
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [
         Endpoint.DataSet(data=data_set)
         for data_set_name, data_set in data_sets.items()
     ]
     self.team_years = Endpoint.DataSet(data=data_sets['TeamYears'])
Ejemplo n.º 22
0
 def __init__(self,
              game_id):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'GameID': game_id
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [Endpoint.DataSet(data=data_set) for data_set_name, data_set in data_sets.items()]
     self.fan_duel_player = Endpoint.DataSet(data=data_sets['FanDuelPlayer'])
Ejemplo n.º 23
0
def minimal_requirement_tests(endpoint, required_params, pause=1):
    status = 'success'
    all_parameters = list(required_params.keys())
    # 1. minimal requirement test with default non-nullable values
    nba_stats_response = NBAStatsHTTP().send_api_request(
        endpoint=endpoint, parameters=required_params)

    # 2. minimal requirement test with pattern matching
    if not nba_stats_response.valid_json():
        parameter_patterns = get_patterns_from_response(
            nba_stats_response=nba_stats_response)
        # Overwrites param with parameter patterns on mismatches.
        for prop in required_params.keys():
            if prop in parameter_patterns:
                pattern = parameter_patterns[prop]
                if pattern in parameter_map[prop]['non-nullable']:
                    map_key = 'non-nullable'
                else:
                    map_key = 'nullable'
                parameter_info_key = parameter_map[prop][map_key][pattern]
                parameter_info = parameter_variations[parameter_info_key]
                required_params[prop] = parameter_info['parameter_value']
        # This error sometimes occurs because LeagueID won't show as as required parameter.
        if '<Error><Message>An error has occurred.</Message></Error>' in nba_stats_response.get_response(
        ):
            required_params['LeagueID'] = '00'
        time.sleep(pause)
        nba_stats_response = NBAStatsHTTP().send_api_request(
            endpoint=endpoint, parameters=required_params)

    if nba_stats_response.valid_json():
        data_sets = nba_stats_response.get_headers_from_data_sets()
        all_parameters += list(nba_stats_response.get_parameters().keys())
    else:
        status = 'invalid'
        print(status, 'failed to pass minimal values test')
        data_sets = {}
    all_parameters = list(set(all_parameters))

    # Update Parameter Pattern Mapping
    all_params = {}
    all_params_errors = {}
    for prop in all_parameters:
        if prop in parameter_map:
            if len(parameter_map[prop]['non-nullable']):
                map_key = 'non-nullable'
            else:
                map_key = 'nullable'
            parameter_info_key = list(parameter_map[prop][map_key].values())[0]
            parameter_info = parameter_variations[parameter_info_key]
            all_params[prop] = parameter_info['parameter_value']
            all_params_errors[prop] = parameter_info['parameter_error_value']
        else:
            print(prop, 'not found in parameter map - minimal test')
            status = 'invalid'
            all_params[prop] = 'a'
            all_params_errors[prop] = 'a'

    return status, all_parameters, data_sets, all_params_errors
Ejemplo n.º 24
0
 def __init__(self,
              league_id=LeagueID.default):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'LeagueID': league_id
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [Endpoint.DataSet(data=data_set) for data_set_name, data_set in data_sets.items()]
     self.defunct_teams = Endpoint.DataSet(data=data_sets['DefunctTeams'])
     self.franchise_history = Endpoint.DataSet(data=data_sets['FranchiseHistory'])
Ejemplo n.º 25
0
def nullable_parameters_test(endpoint, all_parameters):
    skip_endpoints = [
        'boxscoreadvancedv2', 'boxscorefourfactorsv2', 'boxscoremiscv2',
        'boxscorescoringv2', 'boxscoretraditionalv2', 'boxscoreusagev2'
    ]

    if endpoint.lower() in skip_endpoints:
        return []

    non_nullable_list = ['DefenseCategory']
    non_nullable_endpoint_parameters = [
        ['playergamelog', 'Season'],
        ['videodetails', 'Season'],
        ['teamgamelog', 'Season'],
        ['playernextngames', 'Season'],
        ['teamdashptshots', 'Season'],
        ['teamdashptreb', 'Season'],
        ['teamdashptpass', 'Season'],
        ['shotchartdetail', 'ContextMeasure'],
        ['scoreboardv2', 'Season'],
        ['scoreboard', 'Season'],
        ['leaguegamelog', 'Counter'],
        ['playerdashptpass', 'LeagueID'],
        ['playerdashptreb', 'LeagueID'],
        ['playerdashptshotdefend', 'LeagueID'],
        ['playerdashptshots', 'LeagueID'],
        ['shotchartdetail', 'LeagueID'],
        ['teamdashptpass', 'LeagueID'],
        ['teamgamelog', 'SeasonType'],
        ['teamdashptreb', 'LeagueID'],
        ['teamdashptshots', 'LeagueID'],
    ]
    params = {
        prop: ''
        for prop in all_parameters if prop not in non_nullable_list
        and [endpoint.lower(), prop] not in non_nullable_endpoint_parameters
    }

    nba_stats_response = NBAStatsHTTP().send_api_request(endpoint=endpoint,
                                                         parameters=params)

    if 'An error has occurred.' in nba_stats_response.get_response() \
            or 'A value is required' in nba_stats_response.get_response():
        raise Exception(
            'Failed to pass nullable parameters test. Possibly non-nullable value failing.'
        )

    required_parameters = get_required_parameters(nba_stats_response)
    nullable_parameters = [
        prop for prop in list(params.keys()) if prop not in required_parameters
    ]

    return nullable_parameters
Ejemplo n.º 26
0
 def __init__(self, game_id, game_event_id=0):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'GameID': game_id,
             'GameEventID': game_event_id
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [
         Endpoint.DataSet(data=data_set)
         for data_set_name, data_set in data_sets.items()
     ]
Ejemplo n.º 27
0
 def __init__(self,
              league_id=LeagueID.default,
              season=Season.default):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'LeagueID': league_id,
             'SeasonYear': season
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [Endpoint.DataSet(data=data_set) for data_set_name, data_set in data_sets.items()]
     self.results = Endpoint.DataSet(data=data_sets['Results'])
Ejemplo n.º 28
0
 def __init__(self, game_date=GameDate.default, league_id=LeagueID.default):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'GameDate': game_date,
             'LeagueID': league_id
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [
         Endpoint.DataSet(data=data_set)
         for data_set_name, data_set in data_sets.items()
     ]
     self.video_status = Endpoint.DataSet(data=data_sets['VideoStatus'])
Ejemplo n.º 29
0
 def __init__(self,
              team_id,
              league_id=LeagueID.default,
              season_id=SeasonID.default):
     self.nba_response = NBAStatsHTTP().send_api_request(
         endpoint=self.endpoint,
         parameters={
             'TeamID': team_id,
             'LeagueID': league_id,
             'SeasonID': season_id
         },
     )
     data_sets = self.nba_response.get_data_sets()
     self.data_sets = [Endpoint.DataSet(data=data_set) for data_set_name, data_set in data_sets.items()]
     self.career_leaders_by_team = Endpoint.DataSet(data=data_sets['CareerLeadersByTeam'])
Ejemplo n.º 30
0
class CommonPlayoffSeries(Endpoint):
    endpoint = 'commonplayoffseries'
    expected_data = {
        'PlayoffSeries': [
            'GAME_ID', 'HOME_TEAM_ID', 'VISITOR_TEAM_ID', 'SERIES_ID',
            'GAME_NUM'
        ]
    }

    def __init__(self,
                 season=Season.default,
                 league_id_nullable=LeagueIDNullable.default,
                 series_id_nullable=''):
        self.nba_response = NBAStatsHTTP().send_api_request(
            endpoint=self.endpoint,
            parameters={
                'Season': season,
                'LeagueID': league_id_nullable,
                'SeriesID': series_id_nullable
            },
        )
        data_sets = self.nba_response.get_data_sets()
        self.data_sets = [
            Endpoint.DataSet(data=data_set)
            for data_set_name, data_set in data_sets.items()
        ]
        self.playoff_series = Endpoint.DataSet(data=data_sets['PlayoffSeries'])