Python nba_api有没有一种方法可以只查询api的一部分?

Python nba_api有没有一种方法可以只查询api的一部分?,python,api,nba-api,Python,Api,Nba Api,我目前正在为我的网站编写一个模拟程序,目前对API非常满意,然而,当我试图收集一支球队在特定游戏中的得分和对他们的得分时,我能找到的唯一终点是WinProbabilityBP。然而,对于我的模拟,我需要查询一个赛季中每场比赛的API,并且从API返回的数据太大,因为它还包含游戏中每场比赛的详细信息。是否有一种方法可以请求API,但它只返回一个列表,而不是每个游戏的详细信息以及较小的点数统计信息。因为查询时间太长,无法使用。谢谢 这是我的代码,告诉你我的意思 from nba_api.stats.

我目前正在为我的网站编写一个模拟程序,目前对API非常满意,然而,当我试图收集一支球队在特定游戏中的得分和对他们的得分时,我能找到的唯一终点是WinProbabilityBP。然而,对于我的模拟,我需要查询一个赛季中每场比赛的API,并且从API返回的数据太大,因为它还包含游戏中每场比赛的详细信息。是否有一种方法可以请求API,但它只返回一个列表,而不是每个游戏的详细信息以及较小的点数统计信息。因为查询时间太长,无法使用。谢谢

这是我的代码,告诉你我的意思

from nba_api.stats.static import players, teams
from nba_api.stats.endpoints import teamgamelog, winprobabilitypbp
import random as rnd
import numpy as np
import matplotlib.pyplot as plt

#get team ids
team1 = teams.find_teams_by_full_name("Bucks")
team2 = teams.find_teams_by_full_name("Lakers")
team1_id = team1[0]['id']
team2_id = team2[0]['id']

#get all games in specified season for those teams
results1 = teamgamelog.TeamGameLog(team_id=team1_id, season='2019-20').get_dict()
results2 = teamgamelog.TeamGameLog(team_id=team2_id, season='2019-20').get_dict()
games1 = results1['resultSets'][0]['rowSet']
games2 = results2['resultSets'][0]['rowSet']

#create lists with game ids
game_id1 = []
for i in range(len(games1)): 
    game_id1.append(games1[i][1]) 

game_id2 = []
for i in range(len(games2)):
    game_id2.append(games2[i][1])
    

#query API for points scored by team and against team, store those in separate lists (these requests take too long as it returns details on each play in each game of which there is normally 82 games!)
team_points1 = []
opp_points1 = []
for id in game_id1:
    game1_scores = winprobabilitypbp.WinProbabilityPBP(game_id=id, timeout=1000).get_dict()['resultSets'][1]['rowSet']
    if game1_scores[0][3] == team1[0]['abbreviation']:
        team_points1.append(game1_scores[0][4])
        opp_points1.append(game1_scores[0][7])
    else:
        team_points1.append(game1_scores[0][7])
        opp_points1.append(game1_scores[0][4])


#same for other team
team_points2 = []
opp_points2 = []
for id in game_id2:
    game2_scores = winprobabilitypbp.WinProbabilityPBP(game_id=id, timeout=1000).get_dict()['resultSets'][1]['rowSet']
    if game2_scores[0][3] == team2[0]['abbreviation']:
        team_points2.append(game2_scores[0][4])
        opp_points2.append(game2_scores[0][7])
    else:
        team_points2.append(game2_scores[0][7])
        opp_points2.append(game2_scores[0][4])

#use numpy to find mean and standard deviations for each list collected
team1_mean = np.mean(team_points1)
team1_std = np.std(team_points1)

opp1_mean = np.mean(opp_points1)
opp1_std = np.std(opp_points1)

team2_mean = np.mean(team_points2)
team2_std = np.std(team_points2)

opp2_mean = np.mean(opp_points2)
opp2_std = np.std(opp_points2)

#use mean and standard deviations with random to simulate number of points a team will score
team1_sim_pts = int(round((rnd.gauss(team1_mean, team1_std) + rnd.gauss(opp2_mean, opp2_std))) / 2)

team2_sim_pts = int(round((rnd.gauss(team2_mean, team2_std) + rnd.gauss(opp1_mean, opp1_std))) / 2)

#print the scores
print(f"Bucks: {team1_sim_pts}")

print(f"Lakers: {team2_sim_pts}")

如果它在API中有一些选项,您必须阅读文档,但我希望它没有,然后您不能更改它。