nba_api_wrapper 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/nba/game.rb +22 -0
- data/lib/nba/nba.rb +2 -0
- data/lib/nba/play_by_play.rb +16 -0
- data/lib/nba/player.rb +41 -0
- data/lib/nba/stats/leaders.rb +36 -0
- data/lib/nba/stats/player_stats.rb +127 -0
- data/lib/nba/stats/team_stats.rb +64 -0
- data/lib/nba/tracking/tracking_stats.rb +156 -0
- data/lib/nba_api_wrapper.rb +10 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2d82fe54ebf765cb9231c5bb03a9ca0ab4b87919
|
4
|
+
data.tar.gz: 51af1f41d9e6e4e6a3b6cdf51f7bf7726c0456a6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a45ec6619c1644d63325c170b155a95d89b7f9e20e0a04900abc08d552cd2ee321a67cb828d2ca00a79634993887b84b690ddaa705b58379e5c9c3085b4865fe
|
7
|
+
data.tar.gz: 8b81189d949405bf3b9a7cbde33062a7bab90c06cf5fd5407bf5dae7a003f342251eebfe3165416063e7f56b9524dcda9e68bc607dd7203756898c9d4b9e46be
|
data/lib/nba/game.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
class NBA::Game
|
2
|
+
BASE_URI = 'http://data.nba.com/jsonp/5s/json/cms/noseason/scoreboard'
|
3
|
+
|
4
|
+
def self.get_games(date=today_date)
|
5
|
+
url = BASE_URI+"/#{date}/games.json?callback=cb"
|
6
|
+
res = HTTP.get(url)
|
7
|
+
if res.code == 200
|
8
|
+
# THE RESPONSE HERE IS JSONP, SO WE NEED TO PARSE IT
|
9
|
+
len = res.body.to_s.length
|
10
|
+
return JSON.parse(res.body.to_s[3,(len-5)])
|
11
|
+
end
|
12
|
+
return res.code
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def self.today_date
|
17
|
+
d = Date.today
|
18
|
+
d.strftime('%Y%m%d')
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
end
|
data/lib/nba/nba.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
class NBA::PlayByPlay
|
2
|
+
BASE_URI = 'http://stats.nba.com/stats'
|
3
|
+
|
4
|
+
def self.get_plays_for_game(game_id, start_period=1, end_period=10)
|
5
|
+
res = HTTP.get(BASE_URI+'/playbyplayv2', :params => {
|
6
|
+
:GameID => game_id,
|
7
|
+
:EndPeriod => end_period,
|
8
|
+
:StartPeriod => start_period
|
9
|
+
})
|
10
|
+
if res.code == 200
|
11
|
+
return JSON.parse(res.body)
|
12
|
+
end
|
13
|
+
return res.code
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
data/lib/nba/player.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
class NBA::Player
|
2
|
+
BASE_URI = 'http://stats.nba.com/stats'
|
3
|
+
|
4
|
+
def self.get_player(playerId, leagueId='00')
|
5
|
+
res = HTTP.get(BASE_URI+'/commonplayerinfo', :params => {
|
6
|
+
:LeagueID => leagueId,
|
7
|
+
:PlayerID => playerId
|
8
|
+
})
|
9
|
+
if res.code == 200
|
10
|
+
return JSON.parse(res.body)
|
11
|
+
end
|
12
|
+
return res.code
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.get_all_players(is_current_season=true,leagueId='00',season_str=current_season)
|
16
|
+
is_current_season = is_current_season ? 1 : 0
|
17
|
+
res = HTTP.get(BASE_URI+'/commonallplayers', :params => {
|
18
|
+
:IsOnlyCurrentSeason => is_current_season,
|
19
|
+
:LeagueID => leagueId,
|
20
|
+
:Season => season_str
|
21
|
+
})
|
22
|
+
if res.code == 200
|
23
|
+
return JSON.parse(res.body)
|
24
|
+
end
|
25
|
+
return res.code
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.current_season
|
29
|
+
#ROLL THE CURRENT SEASON WHEN WE REACH AUGUST
|
30
|
+
if Date.today.month >= 8
|
31
|
+
last_year = Date.today.year.to_s
|
32
|
+
cur_year = (Date.today.year+1).to_s[-2..-1]
|
33
|
+
"#{last_year}-#{cur_year}"
|
34
|
+
else
|
35
|
+
last_year = (Date.today.year-1).to_s
|
36
|
+
cur_year = Date.today.year.to_s[-2..-1]
|
37
|
+
"#{last_year}-#{cur_year}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end #END OF PLAYER CLASS
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class NBA::Stats
|
2
|
+
class Leaders
|
3
|
+
BASE_URI = 'http://stats.nba.com/stats'
|
4
|
+
|
5
|
+
def self.get_stats(leagueId="00", perMode="PerGame", season="2015-16", seasonType="Regular Season", scope="S", statCategory="PTS")
|
6
|
+
res = HTTP.get(BASE_URI+'/leagueleaders', :params => {
|
7
|
+
:LeagueID => leagueId,
|
8
|
+
:PerMode => perMode,
|
9
|
+
:Season => season,
|
10
|
+
:SeasonType => seasonType,
|
11
|
+
:Scope => scope,
|
12
|
+
:StatCategory => statCategory
|
13
|
+
})
|
14
|
+
if res.code == 200
|
15
|
+
return JSON.parse(res.body)
|
16
|
+
end
|
17
|
+
return res.code
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.all_time(leagueId="00", perMode="PerGame", season="All Time", seasonType="Regular Season", scope="S", statCategory="PTS")
|
21
|
+
res = HTTP.get(BASE_URI+'/leagueleaders', :params => {
|
22
|
+
:LeagueID => leagueId,
|
23
|
+
:PerMode => perMode,
|
24
|
+
:Season => season,
|
25
|
+
:SeasonType => seasonType,
|
26
|
+
:Scope => scope,
|
27
|
+
:StatCategory => statCategory
|
28
|
+
})
|
29
|
+
if res.code == 200
|
30
|
+
return JSON.parse(res.body)
|
31
|
+
end
|
32
|
+
return res.code
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
class NBA::Stats
|
2
|
+
class Player
|
3
|
+
BASE_URI = 'http://stats.nba.com/stats'
|
4
|
+
|
5
|
+
def self.get_stats(measureType="Base", perMode="PerGame", plusMinus="N", paceAdjust="N", rank="N", leagueID="00", season="2015-16", seasonType="Regular Season", pORound=0, outcome=nil, location=nil, month=0, seasonSegment=nil, dateFrom=nil, dateTo=nil, opponentTeamID=0, vsConference=nil, vsDivision=nil, teamID=0, conference=nil, division=nil, gameSegment=nil, period=0, shotClockRange=nil, lastNGames=0, gameScope=nil, playerExperience=nil, playerPosition=nil, starterBench=nil, draftYear=nil, draftPick=nil, college=nil, country=nil, height=nil, weight=nil)
|
6
|
+
res = HTTP.headers(:referer => "http://stats.nba.com").get(BASE_URI+'/leaguedashplayerstats', :params => {
|
7
|
+
:MeasureType => measureType,
|
8
|
+
:PerMode => perMode,
|
9
|
+
:PlusMinus => plusMinus,
|
10
|
+
:PaceAdjust => paceAdjust,
|
11
|
+
:Rank => rank,
|
12
|
+
:LeagueID => leagueID,
|
13
|
+
:Season => season,
|
14
|
+
:SeasonType => seasonType,
|
15
|
+
:PORound => pORound,
|
16
|
+
:Outcome => outcome,
|
17
|
+
:Location => location,
|
18
|
+
:Month => month,
|
19
|
+
:SeasonSegment => seasonSegment,
|
20
|
+
:DateFrom => dateFrom,
|
21
|
+
:DateTo => dateTo,
|
22
|
+
:OpponentTeamID => opponentTeamID,
|
23
|
+
:VsConference => vsConference,
|
24
|
+
:VsDivision => vsDivision,
|
25
|
+
:TeamID => teamID,
|
26
|
+
:Conference => conference,
|
27
|
+
:Division => division,
|
28
|
+
:GameSegment => gameSegment,
|
29
|
+
:Period => period,
|
30
|
+
:ShotClockRange => shotClockRange,
|
31
|
+
:LastNGames => lastNGames,
|
32
|
+
:GameScope => gameScope,
|
33
|
+
:PlayerExperience => playerExperience,
|
34
|
+
:PlayerPosition => playerPosition,
|
35
|
+
:StarterBench => starterBench,
|
36
|
+
:DraftYear => draftYear,
|
37
|
+
:DraftPick => draftPick,
|
38
|
+
:College => college,
|
39
|
+
:Country => country,
|
40
|
+
:Height => height,
|
41
|
+
:Weight => weight
|
42
|
+
})
|
43
|
+
if res.code == 200
|
44
|
+
return JSON.parse(res.body)
|
45
|
+
end
|
46
|
+
return res.code
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.get_clutch_stats(measureType="Base",perMode="PerGame",plusMinus="N",paceAdjust="N",rank="N",leagueID="00",season="2015-16",seasonType="Regular Season",pORound=0,outcome=nil,location=nil,month=0,seasonSegment=nil,dateFrom=nil,dateTo=nil,opponentTeamID=0,vsConference=nil,vsDivision=nil,teamID=0,conference=nil,division=nil,gameSegment=nil,period=0,shotClockRange=nil,lastNGames=0,clutchTime="Last 5 Minutes",aheadBehind="Ahead or Behind",pointDiff=5,gameScope=nil,playerExperience=nil,playerPosition=nil,starterBench=nil,draftYear=nil,draftPick=nil,college=nil,country=nil,height=nil,weight=nil)
|
50
|
+
res = HTTP.get(BASE_URI+'/leaguedashplayerclutch', :params => {
|
51
|
+
:MeasureType => measureType,
|
52
|
+
:PerMode => perMode,
|
53
|
+
:PlusMinus => plusMinus,
|
54
|
+
:PaceAdjust => paceAdjust,
|
55
|
+
:Rank => rank,
|
56
|
+
:LeagueID => leagueID,
|
57
|
+
:Season => season,
|
58
|
+
:SeasonType => seasonType,
|
59
|
+
:PORound => pORound,
|
60
|
+
:Outcome => outcome,
|
61
|
+
:Location => location,
|
62
|
+
:Month => month,
|
63
|
+
:SeasonSegment => seasonSegment,
|
64
|
+
:DateFrom => dateFrom,
|
65
|
+
:DateTo => dateTo,
|
66
|
+
:OpponentTeamID => opponentTeamID,
|
67
|
+
:VsConference => vsConference,
|
68
|
+
:VsDivision => vsDivision,
|
69
|
+
:TeamID => teamID,
|
70
|
+
:Conference => conference,
|
71
|
+
:Division => division,
|
72
|
+
:GameSegment => gameSegment,
|
73
|
+
:Period => period,
|
74
|
+
:ShotClockRange => shotClockRange,
|
75
|
+
:LastNGames => lastNGames,
|
76
|
+
:ClutchTime => clutchTime,
|
77
|
+
:AheadBehind => aheadBehind,
|
78
|
+
:PointDiff => pointDiff,
|
79
|
+
:GameScope => gameScope,
|
80
|
+
:PlayerExperience => playerExperience,
|
81
|
+
:PlayerPosition => playerPosition,
|
82
|
+
:StarterBench => starterBench,
|
83
|
+
:DraftYear => draftYear,
|
84
|
+
:DraftPick => draftPick,
|
85
|
+
:College => college,
|
86
|
+
:Country => country,
|
87
|
+
:Height => height,
|
88
|
+
:Weight => weight
|
89
|
+
})
|
90
|
+
if res.code == 200
|
91
|
+
return JSON.parse(res.body)
|
92
|
+
end
|
93
|
+
return res.code
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.get_dashboard_general(measureType="Base",perMode="PerGame",plusMinus="N",paceAdjust="N",rank="N",season="2015-16",seasonType="Regular Season",playerId=0,outcome=nil,location=nil,month=0,seasonSegment=nil,dateFrom=nil,dateTo=nil,opponentTeamID=0,vsConference=nil,vsDivision=nil,gameSegment=nil,period=0,lastNGames=0)
|
97
|
+
res = HTTP.headers(:referer => "http://stats.nba.com").get(BASE_URI+'/playerdashboardbygeneralsplits', :params => {
|
98
|
+
:MeasureType => measureType,
|
99
|
+
:PerMode => perMode,
|
100
|
+
:PlusMinus => plusMinus,
|
101
|
+
:PaceAdjust => paceAdjust,
|
102
|
+
:Rank => rank,
|
103
|
+
:Season => season,
|
104
|
+
:SeasonType => seasonType,
|
105
|
+
:PlayerID => playerId,
|
106
|
+
:Outcome => outcome,
|
107
|
+
:Location => location,
|
108
|
+
:Month => month,
|
109
|
+
:SeasonSegment => seasonSegment,
|
110
|
+
:DateFrom => dateFrom,
|
111
|
+
:DateTo => dateTo,
|
112
|
+
:OpponentTeamID => opponentTeamID,
|
113
|
+
:VsConference => vsConference,
|
114
|
+
:VsDivision => vsDivision,
|
115
|
+
:GameSegment => gameSegment,
|
116
|
+
:Period => period,
|
117
|
+
:LastNGames => lastNGames
|
118
|
+
})
|
119
|
+
if res.code == 200
|
120
|
+
return JSON.parse(res.body)
|
121
|
+
end
|
122
|
+
return JSON.parse(res.body)
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
class NBA::Stats
|
2
|
+
class Team
|
3
|
+
BASE_URI = 'http://stats.nba.com/stats'
|
4
|
+
#THIS SHOULD BE REFACTORED TO ACCEPT SPLAT PARAMS
|
5
|
+
def self.get_team_stats(measureType="Advanced",perMode="Totals",plusMinus="N",paceAdjust="N",rank="N",leagueID="00",season="2015-16",seasonType="Regular Season",pORound=0,outcome=nil,location=nil,month=0,seasonSegment=nil,dateFrom=nil,dateTo=nil,opponentTeamID=0,vsConference=nil,vsDivision=nil,teamID=0,conference=nil,division=nil,gameSegment=nil,period=0,shotClockRange=nil,lastNGames=0,gameScope=nil,playerExperience=nil,playerPosition=nil,starterBench=nil)
|
6
|
+
res = HTTP.get(BASE_URI+'/leaguedashteamstats', :params => {
|
7
|
+
:MeasureType => measureType,
|
8
|
+
:PerMode => perMode,
|
9
|
+
:PlusMinus => plusMinus,
|
10
|
+
:PaceAdjust => paceAdjust,
|
11
|
+
:Rank => rank,
|
12
|
+
:LeagueID => leagueID,
|
13
|
+
:Season => season,
|
14
|
+
:SeasonType => seasonType,
|
15
|
+
:PORound => pORound,
|
16
|
+
:Outcome => outcome,
|
17
|
+
:Location => location,
|
18
|
+
:Month => month,
|
19
|
+
:SeasonSegment => seasonSegment,
|
20
|
+
:DateFrom => dateFrom,
|
21
|
+
:DateTo => dateTo,
|
22
|
+
:OpponentTeamID => opponentTeamID,
|
23
|
+
:VsConference => vsConference,
|
24
|
+
:VsDivision => vsDivision,
|
25
|
+
:TeamID => teamID,
|
26
|
+
:Conference => conference,
|
27
|
+
:Division => division,
|
28
|
+
:GameSegment => gameSegment,
|
29
|
+
:Period => period,
|
30
|
+
:ShotClockRange => shotClockRange,
|
31
|
+
:LastNGames => lastNGames,
|
32
|
+
:GameScope => gameScope,
|
33
|
+
:PlayerExperience => playerExperience,
|
34
|
+
:PlayerPosition => playerPosition,
|
35
|
+
:StarterBench => starterBench
|
36
|
+
})
|
37
|
+
if res.code == 200
|
38
|
+
return JSON.parse(res.body)
|
39
|
+
end
|
40
|
+
return res.code
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.get_teams
|
44
|
+
r = self.get_team_stats
|
45
|
+
# CHECK IF THE RESPONSE FAILED, IF SO RETURN THE FAILURE
|
46
|
+
if r.is_a? Numeric
|
47
|
+
r
|
48
|
+
else
|
49
|
+
teams_hash = {}
|
50
|
+
teams = r["resultSets"].first["rowSet"]
|
51
|
+
teams.each_with_index do |val, index|
|
52
|
+
teams_hash[teams[index][0]] = teams[index][1]
|
53
|
+
end
|
54
|
+
teams_hash
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.get_team_by_id(id)
|
59
|
+
teams = get_teams
|
60
|
+
teams[id]
|
61
|
+
end
|
62
|
+
|
63
|
+
end #END OF TEAM STATS CLASS
|
64
|
+
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
class NBA::Tracking
|
2
|
+
class Stats
|
3
|
+
BASE_URI = 'http://stats.nba.com/stats'
|
4
|
+
|
5
|
+
def self.get_player_shots(perMode="PerGame",leagueID="00",season="2015-16",seasonType="Regular Season",pORound=0,closeDefDistRange=nil,shotClockRange=nil,shotDistRange=nil,touchTimeRange=nil,dribbleRange=nil,generalRange="Overall",teamID=0,outcome=nil,location=nil,month=0,seasonSegment=nil,dateFrom=nil,dateTo=nil,opponentTeamID=0,vsConference=nil,vsDivision=nil,conference=nil,division=nil,gameSegment=nil,period=0,lastNGames=0,draftYear=nil,draftPick=nil,college=nil,country=nil,height=nil,weight=nil,playerExperience=nil,playerPosition=nil,starterBench=nil)
|
6
|
+
res = HTTP.get(BASE_URI+'/leaguedashplayerptshot', :params => {
|
7
|
+
:PerMode => perMode,
|
8
|
+
:LeagueID => leagueID,
|
9
|
+
:Season => season,
|
10
|
+
:SeasonType => seasonType,
|
11
|
+
:PORound => pORound,
|
12
|
+
:CloseDefDistRange => closeDefDistRange,
|
13
|
+
:ShotClockRange => shotClockRange,
|
14
|
+
:ShotDistRange => shotDistRange,
|
15
|
+
:TouchTimeRange => touchTimeRange,
|
16
|
+
:DribbleRange => dribbleRange,
|
17
|
+
:GeneralRange => generalRange,
|
18
|
+
:TeamID => teamID,
|
19
|
+
:Outcome => outcome,
|
20
|
+
:Location => location,
|
21
|
+
:Month => month,
|
22
|
+
:SeasonSegment => seasonSegment,
|
23
|
+
:DateFrom => dateFrom,
|
24
|
+
:DateTo => dateTo,
|
25
|
+
:OpponentTeamID => opponentTeamID,
|
26
|
+
:VsConference => vsConference,
|
27
|
+
:VsDivision => vsDivision,
|
28
|
+
:Conference => conference,
|
29
|
+
:Division => division,
|
30
|
+
:GameSegment => gameSegment,
|
31
|
+
:Period => period,
|
32
|
+
:LastNGames => lastNGames,
|
33
|
+
:DraftYear => draftYear,
|
34
|
+
:DraftPick => draftPick,
|
35
|
+
:College => college,
|
36
|
+
:Country => country,
|
37
|
+
:Height => height,
|
38
|
+
:Weight => weight,
|
39
|
+
:PlayerExperience => playerExperience,
|
40
|
+
:PlayerPosition => playerPosition,
|
41
|
+
:StarterBench => starterBench
|
42
|
+
})
|
43
|
+
if res.code == 200
|
44
|
+
return JSON.parse(res.body)
|
45
|
+
end
|
46
|
+
return res.code
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.get_player_defense(perMode="PerGame",leagueID="00",season="2015-16",seasonType="Regular Season",pORound=0,playerID=nil,teamID=0,outcome=nil,location=nil,month=0,seasonSegment=nil,dateFrom=nil,dateTo=nil,opponentTeamID=0,vsConference=nil,vsDivision=nil,conference=nil,division=nil,gameSegment=nil,period=0,lastNGames=0,draftYear=nil,draftPick=nil,college=nil,country=nil,height=nil,weight=nil,playerExperience=nil,playerPosition=nil,starterBench=nil,defenseCategory="Overall")
|
50
|
+
res = HTTP.get(BASE_URI+'/leaguedashptdefend', :params => {
|
51
|
+
:PerMode => perMode,
|
52
|
+
:LeagueID => leagueID,
|
53
|
+
:Season => season,
|
54
|
+
:SeasonType => seasonType,
|
55
|
+
:PORound => pORound,
|
56
|
+
:PlayerID => playerID,
|
57
|
+
:TeamID => teamID,
|
58
|
+
:Outcome => outcome,
|
59
|
+
:Location => location,
|
60
|
+
:Month => month,
|
61
|
+
:SeasonSegment => seasonSegment,
|
62
|
+
:DateFrom => dateFrom,
|
63
|
+
:DateTo => dateTo,
|
64
|
+
:OpponentTeamID => opponentTeamID,
|
65
|
+
:VsConference => vsConference,
|
66
|
+
:VsDivision => vsDivision,
|
67
|
+
:Conference => conference,
|
68
|
+
:Division => division,
|
69
|
+
:GameSegment => gameSegment,
|
70
|
+
:Period => period,
|
71
|
+
:LastNGames => lastNGames,
|
72
|
+
:DraftYear => draftYear,
|
73
|
+
:DraftPick => draftPick,
|
74
|
+
:College => college,
|
75
|
+
:Country => country,
|
76
|
+
:Height => height,
|
77
|
+
:Weight => weight,
|
78
|
+
:PlayerExperience => playerExperience,
|
79
|
+
:PlayerPosition => playerPosition,
|
80
|
+
:StarterBench => starterBench,
|
81
|
+
:DefenseCategory => defenseCategory
|
82
|
+
})
|
83
|
+
if res.code == 200
|
84
|
+
return JSON.parse(res.body)
|
85
|
+
end
|
86
|
+
return res.code
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
def self.get_team_shots(perMode="PerGame",leagueID="00",season="2015-16",seasonType="Regular Season",pORound=0,closeDefDistRange=nil,shotClockRange=nil,shotDistRange=nil,touchTimeRange=nil,dribbleRange=nil,generalRange="Overall",teamID=0,outcome=nil,location=nil,month=0,seasonSegment=nil,dateFrom=nil,dateTo=nil,opponentTeamID=0,vsConference=nil,vsDivision=nil,conference=nil,division=nil,gameSegment=nil,period=0,lastNGames=0)
|
91
|
+
res = HTTP.get(BASE_URI+'/leaguedashteamptshot', :params => {
|
92
|
+
:PerMode => perMode,
|
93
|
+
:LeagueID => leagueID,
|
94
|
+
:Season => season,
|
95
|
+
:SeasonType => seasonType,
|
96
|
+
:PORound => pORound,
|
97
|
+
:CloseDefDistRange => closeDefDistRange,
|
98
|
+
:ShotClockRange => shotClockRange,
|
99
|
+
:ShotDistRange => shotDistRange,
|
100
|
+
:TouchTimeRange => touchTimeRange,
|
101
|
+
:DribbleRange => dribbleRange,
|
102
|
+
:GeneralRange => generalRange,
|
103
|
+
:TeamID => teamID,
|
104
|
+
:Outcome => outcome,
|
105
|
+
:Location => location,
|
106
|
+
:Month => month,
|
107
|
+
:SeasonSegment => seasonSegment,
|
108
|
+
:DateFrom => dateFrom,
|
109
|
+
:DateTo => dateTo,
|
110
|
+
:OpponentTeamID => opponentTeamID,
|
111
|
+
:VsConference => vsConference,
|
112
|
+
:VsDivision => vsDivision,
|
113
|
+
:Conference => conference,
|
114
|
+
:Division => division,
|
115
|
+
:GameSegment => gameSegment,
|
116
|
+
:Period => period,
|
117
|
+
:LastNGames => lastNGames
|
118
|
+
})
|
119
|
+
if res.code == 200
|
120
|
+
return JSON.parse(res.body)
|
121
|
+
end
|
122
|
+
return res.code
|
123
|
+
end
|
124
|
+
|
125
|
+
def self.get_team_defense(perMode="PerGame",leagueID="00",season="2015-16",seasonType="Regular Season",pORound=0,teamID=0,outcome=nil,location=nil,month=0,seasonSegment=nil,dateFrom=nil,dateTo=nil,opponentTeamID=0,vsConference=nil,vsDivision=nil,conference=nil,division=nil,gameSegment=nil,period=0,lastNGames=0,defenseCategory="Overall")
|
126
|
+
res = HTTP.get(BASE_URI+'/leaguedashptteamdefend', :params => {
|
127
|
+
:PerMode => perMode,
|
128
|
+
:LeagueID => leagueID,
|
129
|
+
:Season => season,
|
130
|
+
:SeasonType => seasonType,
|
131
|
+
:PORound => pORound,
|
132
|
+
:TeamID => teamID,
|
133
|
+
:Outcome => outcome,
|
134
|
+
:Location => location,
|
135
|
+
:Month => month,
|
136
|
+
:SeasonSegment => seasonSegment,
|
137
|
+
:DateFrom => dateFrom,
|
138
|
+
:DateTo => dateTo,
|
139
|
+
:OpponentTeamID => opponentTeamID,
|
140
|
+
:VsConference => vsConference,
|
141
|
+
:VsDivision => vsDivision,
|
142
|
+
:Conference => conference,
|
143
|
+
:Division => division,
|
144
|
+
:GameSegment => gameSegment,
|
145
|
+
:Period => period,
|
146
|
+
:LastNGames => lastNGames,
|
147
|
+
:DefenseCategory => defenseCategory
|
148
|
+
})
|
149
|
+
if res.code == 200
|
150
|
+
return JSON.parse(res.body)
|
151
|
+
end
|
152
|
+
return res.code
|
153
|
+
end
|
154
|
+
|
155
|
+
end
|
156
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'http'
|
2
|
+
require 'json'
|
3
|
+
require 'nba/nba'
|
4
|
+
require 'nba/player'
|
5
|
+
require 'nba/play_by_play'
|
6
|
+
require 'nba/game'
|
7
|
+
require 'nba/stats/team_stats'
|
8
|
+
require 'nba/stats/leaders'
|
9
|
+
require 'nba/stats/player_stats'
|
10
|
+
require 'nba/tracking/tracking_stats'
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nba_api_wrapper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jesse Mills
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.4.0
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.4.0
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.4.0
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.4.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: http
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 1.0.2
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '1.0'
|
43
|
+
type: :development
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 1.0.2
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '1.0'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: json
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 1.8.1
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.8.1
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.8.1
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 1.8.1
|
73
|
+
description: A simple gem to get the NBA API endpoints
|
74
|
+
email: jessemills1989@gmail.com
|
75
|
+
executables: []
|
76
|
+
extensions: []
|
77
|
+
extra_rdoc_files: []
|
78
|
+
files:
|
79
|
+
- lib/nba/game.rb
|
80
|
+
- lib/nba/nba.rb
|
81
|
+
- lib/nba/play_by_play.rb
|
82
|
+
- lib/nba/player.rb
|
83
|
+
- lib/nba/stats/leaders.rb
|
84
|
+
- lib/nba/stats/player_stats.rb
|
85
|
+
- lib/nba/stats/team_stats.rb
|
86
|
+
- lib/nba/tracking/tracking_stats.rb
|
87
|
+
- lib/nba_api_wrapper.rb
|
88
|
+
homepage:
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.4.5.1
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: NBA API Wrapper
|
112
|
+
test_files: []
|