Player & Team Stats
Access game-by-game player statistics and aggregate team/player stats
Player & Team Statistics
Access comprehensive player game logs and aggregate statistics with advanced filtering options for building analytics platforms and betting research tools.
Endpoints
GET /players/{id}/historicData
/players/{id}/historicDataRetrieve complete game-by-game statistics for a player across all seasons.
Example:
response = requests.get(
f"{base_url}/players/PLYR_abc123def456/historicData",
headers=headers
)
games = response.json()GET /marketSelections/{id}/historicData
/marketSelections/{id}/historicDataGet game-by-game statistics for the player/team in a specific market selection, with extensive filtering options.
Example:
response = requests.get(
f"{base_url}/marketSelections/MRKT_def456abc789/historicData",
headers=headers,
params={
"home": "true",
"gamesBack": 10
}
)
games = response.json()GET /marketSelections/{id}/metadata
/marketSelections/{id}/metadataAccess aggregate statistics (season averages, totals) for teams and players.
Example:
response = requests.get(
f"{base_url}/marketSelections/MRKT_def456abc789/metadata",
headers=headers,
params={
"playerAggStats": "true",
"teamAggStats": "true",
"playerAggStatsSeason": "2024,2023" # Multiple seasons
}
)
metadata = response.json()Player Game Logs
Basic Usage
Get all games for a player:
import requests
base_url = "https://api.sharpsports.io/v1"
headers = {"Authorization": "Token sk_test_your_key_here"}
player_id = "PLYR_abc123def456789012345678901234"
response = requests.get(
f"{base_url}/players/{player_id}/historicData",
headers=headers
)
games = response.json()
# Display recent games
for game in games[:10]:
date = game['eventDate']
opponent = game['opponent']['abbr']
points = game.get('points', 0)
print(f"{date} vs {opponent}: {points} pts")Response Structure
Each game includes:
{
"id": "PGME_abc123def456",
"eventDate": "2024-01-15",
"event": {
"id": "EVNT_xyz789abc012",
"name": "Lakers @ Warriors"
},
"opponent": {
"id": "TEAM_warriors",
"abbr": "GSW",
"fullName": "Golden State Warriors"
},
"isHome": false,
"points": 28,
"rebounds": 7,
"assists": 10,
"minutes": 38,
// ... all available stats for the sport
}Advanced Filtering
Use the /marketSelections/{id}/historicData endpoint for advanced filtering:
Home/Away Splits
# Get only home games
home_games = requests.get(
f"{base_url}/marketSelections/{mrkt_id}/historicData",
headers=headers,
params={"home": "true"}
).json()
# Get only away games
away_games = requests.get(
f"{base_url}/marketSelections/{mrkt_id}/historicData",
headers=headers,
params={"away": "true"}
).json()Recent Games
# Get last 10 games
recent = requests.get(
f"{base_url}/marketSelections/{mrkt_id}/historicData",
headers=headers,
params={"gamesBack": 10}
).json()
# Get last 5 games
last_five = requests.get(
f"{base_url}/marketSelections/{mrkt_id}/historicData",
headers=headers,
params={"gamesBack": 5}
).json()Opponent Filtering
# Games vs specific opponent
vs_opponent = requests.get(
f"{base_url}/marketSelections/{mrkt_id}/historicData",
headers=headers,
params={"opponent": "TEAM_celtics"}
).json()
# Games vs event opponent (upcoming game)
vs_next_opponent = requests.get(
f"{base_url}/marketSelections/{mrkt_id}/historicData",
headers=headers,
params={"vsOpponent": "true"}
).json()MLB Pitcher Filtering
# Games vs left-handed pitchers
vs_lhp = requests.get(
f"{base_url}/marketSelections/{mrkt_id}/historicData",
headers=headers,
params={"pitcher": "L"}
).json()
# Games vs right-handed pitchers
vs_rhp = requests.get(
f"{base_url}/marketSelections/{mrkt_id}/historicData",
headers=headers,
params={"pitcher": "R"}
).json()
# Games vs specific pitcher
vs_specific = requests.get(
f"{base_url}/marketSelections/{mrkt_id}/historicData",
headers=headers,
params={"pitcher": "PLYR_kershaw"}
).json()
# Games vs event starting pitcher
vs_event_pitcher = requests.get(
f"{base_url}/marketSelections/{mrkt_id}/historicData",
headers=headers,
params={"vsStartingPitcher": "true"}
).json()Combining Filters
# Last 10 home games vs left-handed pitchers
filtered = requests.get(
f"{base_url}/marketSelections/{mrkt_id}/historicData",
headers=headers,
params={
"home": "true",
"gamesBack": 10,
"pitcher": "L"
}
).json()Aggregate Statistics
Get season averages and totals:
Player Aggregate Stats
response = requests.get(
f"{base_url}/marketSelections/{mrkt_id}/metadata",
headers=headers,
params={
"playerAggStats": "true",
"playerAggStatsSeason": "2024,2023,2022"
}
).json()
# Access player stats
if 'playerAggregateStats' in response:
player_stats = response['playerAggregateStats']
print(f"Season Average: {player_stats.get('average', 0):.1f}")
print(f"Games Played: {player_stats.get('games', 0)}")
print(f"Season Total: {player_stats.get('total', 0):.1f}")Team Aggregate Stats
response = requests.get(
f"{base_url}/marketSelections/{mrkt_id}/metadata",
headers=headers,
params={
"teamAggStats": "true",
"teamAggStatsSeason": "2024"
}
).json()
# Access team stats
if 'teamAggregateStats' in response:
team_stats = response['teamAggregateStats']
print(f"Team PPG: {team_stats.get('pointsPerGame', 0):.1f}")
print(f"Opponent PPG: {team_stats.get('oppPointsPerGame', 0):.1f}")Filtered Aggregate Stats
Get aggregate stats that match your filters:
response = requests.get(
f"{base_url}/marketSelections/{mrkt_id}/metadata",
headers=headers,
params={
"playerAggStats": "true",
"filteredPlayerAggStats": "true", # Include filtered version
"home": "true", # Filter: home games only
"gamesBack": 10 # Filter: last 10 games
}
).json()
# Original (season-long)
season_avg = response['playerAggregateStats']['average']
# Filtered (last 10 home games)
filtered_avg = response['filteredPlayerAggregateStats']['average']
print(f"Season Average: {season_avg:.1f}")
print(f"Last 10 Home Games Average: {filtered_avg:.1f}")Complete Examples
Player Prop Analysis
Analyze a player's recent performance:
def analyze_player_prop(market_selection_id):
"""Comprehensive player prop analysis"""
# Get metadata with aggregate stats
metadata = requests.get(
f"{base_url}/marketSelections/{market_selection_id}/metadata",
headers=headers,
params={
"playerAggStats": "true",
"teamAggStats": "true"
}
).json()
player = metadata['player']
prop = metadata['proposition']
print(f"\nPlayer: {player['fullName']}")
print(f"Prop: {prop}")
# Get recent game logs
games = requests.get(
f"{base_url}/marketSelections/{market_selection_id}/historicData",
headers=headers,
params={"gamesBack": 10}
).json()
# Calculate averages
stat_key = prop.lower().replace('player_', '')
values = [g.get(stat_key, 0) for g in games]
avg = sum(values) / len(values) if values else 0
print(f"\nLast 10 Games Average: {avg:.1f}")
# Season average
if 'playerAggregateStats' in metadata:
season_avg = metadata['playerAggregateStats'].get('average', 0)
print(f"Season Average: {season_avg:.1f}")
# Home/Away splits
home_games = requests.get(
f"{base_url}/marketSelections/{market_selection_id}/historicData",
headers=headers,
params={"home": "true", "gamesBack": 5}
).json()
away_games = requests.get(
f"{base_url}/marketSelections/{market_selection_id}/historicData",
headers=headers,
params={"away": "true", "gamesBack": 5}
).json()
home_avg = sum(g.get(stat_key, 0) for g in home_games) / len(home_games) if home_games else 0
away_avg = sum(g.get(stat_key, 0) for g in away_games) / len(away_games) if away_games else 0
print(f"\nHome Average (L5): {home_avg:.1f}")
print(f"Away Average (L5): {away_avg:.1f}")
return metadata, games
# Usage
analyze_player_prop("MRKT_def456abc789012345678901234567")Situational Stats
Compare different situations:
def compare_situations(market_selection_id):
"""Compare player performance in different situations"""
situations = {
"Overall (L10)": {"gamesBack": 10},
"Home (L5)": {"home": "true", "gamesBack": 5},
"Away (L5)": {"away": "true", "gamesBack": 5},
"vs LHP": {"pitcher": "L"},
"vs RHP": {"pitcher": "R"}
}
print("Situational Performance:")
print("-" * 50)
for situation, params in situations.items():
games = requests.get(
f"{base_url}/marketSelections/{market_selection_id}/historicData",
headers=headers,
params=params
).json()
if games:
# Calculate average
avg = sum(g.get('points', 0) for g in games) / len(games)
print(f"{situation:20} {avg:6.1f} ({len(games)} games)")
compare_situations("MRKT_def456abc789012345678901234567")Available Statistics
Statistics vary by sport:
Basketball (NBA/NCAAB):
points,rebounds,assists,steals,blocksthreePointersMade,freeThrows,fieldGoalsminutes,plusMinus,doubleDoubles
Football (NFL/NCAAF):
passingYards,passingTDs,completions,attemptsrushingYards,rushingTDs,rushingAttemptsreceivingYards,receivingTDs,receptions,targets
Baseball (MLB):
hits,homeRuns,rbis,stolenBasesbattingAverage,onBasePercentage,sluggingPercentagestrikeouts,earnedRuns,wins(pitchers)
Hockey (NHL):
goals,assists,points,shotsplusMinus,penaltyMinutessaves,goalsAgainst,savePercentage(goalies)
Query Parameters Reference
/players/{id}/historicData
/players/{id}/historicDataNo query parameters - returns all games for the player.
/marketSelections/{id}/historicData
/marketSelections/{id}/historicData| Parameter | Type | Description |
|---|---|---|
home | boolean | Filter to home games only |
away | boolean | Filter to away games only |
location | string | Filter by venue, opponent, or location |
pitcher | string | MLB: Filter by pitcher hand (L/R) or pitcher ID |
opponent | string | Filter by opponent team ID |
vsOpponent | boolean | Filter to games vs event opponent |
vsStartingPitcher | boolean | MLB: Games vs event starting pitcher |
vsStartingPitcherHand | boolean | MLB: Games vs event pitcher hand |
gamesWithout | string | Filter to games without injured players |
winningMargin | number | Filter by winning margin threshold |
gamesBack | number | Limit to most recent N games or current season |
seasonType | string | Filter by season type (regular/playoff) |
/marketSelections/{id}/metadata
/marketSelections/{id}/metadata| Parameter | Type | Description |
|---|---|---|
teamAggStats | boolean | Include team aggregate statistics |
filteredTeamAggStats | boolean | Include filtered team aggregate stats |
playerAggStats | boolean | Include player aggregate statistics |
filteredPlayerAggStats | boolean | Include filtered player aggregate stats |
teamAggStatsSeason | string | Comma-separated years for team stats |
playerAggStatsSeason | string | Comma-separated years for player stats |
Note: Filtered aggregate stats reflect the same filters applied to historic data (home/away, gamesBack, etc.).
Need Help?
- π§ Support: [email protected]
- π API Reference: /reference
- π¬ Discord: Join our developer community
Updated 18 days ago