Python wrapper for the Euroleague Basketball API
Project description
py-euroleague
A Python wrapper for the Euroleague Basketball API. Access game statistics, player performance, team analytics, standings, and more.
Installation
pip install py-euroleague
Quick Start
from euroleague import EuroleagueClient
client = EuroleagueClient()
# Get current season standings
standings = client.v3.standings.basic("E", "E2025", round_number=20)
# Get top scorers
leaders = client.v3.player_stats.leaders("E", season_code="E2025", limit=10)
for player in leaders["points"][:5]:
name = player["details"]["name"]
ppg = player["average"]
print(f"{name}: {ppg:.1f} PPG")
client.close()
Or use as a context manager:
with EuroleagueClient() as client:
clubs = client.v2.clubs.list(limit=10)
print(f"Found {len(clubs['data'])} clubs")
Statistics & Analytics
Player Statistics
with EuroleagueClient() as client:
# Season leaders across all categories
leaders = client.v3.player_stats.leaders(
competition_code="E",
season_code="E2025",
limit=20
)
# Access different stat categories
top_scorers = leaders["points"]
top_rebounders = leaders["rebounds"]
top_playmakers = leaders["assists"]
top_pir = leaders["pir"] # Performance Index Rating
# Traditional stats (per-game averages)
traditional = client.v3.player_stats.traditional(
competition_code="E",
season_code="E2025"
)
# Advanced analytics
advanced = client.v3.player_stats.advanced(
competition_code="E",
season_code="E2025"
)
Team Statistics
with EuroleagueClient() as client:
# Team traditional stats
team_stats = client.v3.team_stats.traditional(
competition_code="E",
season_code="E2025"
)
for team in team_stats["teams"][:5]:
name = team["team"]["name"]
ppg = team["pointsScored"]
print(f"{name}: {ppg:.1f} PPG")
# Team advanced stats
advanced = client.v3.team_stats.advanced(
competition_code="E",
season_code="E2025"
)
# Opponent stats (defensive analysis)
opponent_stats = client.v3.team_stats.opponents(
competition_code="E",
season_code="E2025"
)
Game Box Scores
with EuroleagueClient() as client:
# Get game stats with full box score
game_stats = client.v3.stats.get_game_stats("E", "E2025", game_code=100)
# Home team stats
home = game_stats["local"]
home_total = home["total"]
print(f"Home: {home_total['points']} points")
# Individual player stats
for player in home["players"]:
name = player["player"]["person"]["name"]
pts = player["stats"]["points"]
reb = player["stats"]["totalRebounds"]
ast = player["stats"]["assistances"]
print(f" {name}: {pts} PTS, {reb} REB, {ast} AST")
Live Game Data
Access real-time game data including play-by-play events and shot locations with coordinates.
Play-by-Play
Get detailed play-by-play data for any game:
with EuroleagueClient() as client:
# Get play-by-play for a game
pbp = client.live.play_by_play.get("E2025", game_code=241)
print(f"{pbp.team_a} vs {pbp.team_b}")
print(f"Total plays: {pbp.total_plays}")
# Get plays by quarter
for q in range(1, 5):
quarter_plays = pbp.get_quarter(q)
print(f"Q{q}: {len(quarter_plays)} plays")
# Filter scoring plays
for play in pbp.get_scoring_plays()[:10]:
print(f"{play.marker_time} - {play.player}: {play.play_info} ({play.points_scored} pts)")
# Get plays by team or player
team_plays = pbp.get_plays_by_team("MAD")
player_plays = pbp.get_plays_by_player("P001")
Shot Location Data
Get shot data with court coordinates for shot chart analysis:
with EuroleagueClient() as client:
# Get shot data for a game
shots = client.live.shots.get("E2025", game_code=241)
print(f"Total shots: {shots.total_shots}")
print(f"FG%: {shots.get_field_goal_percentage():.1f}%")
print(f"3PT%: {shots.get_three_point_percentage():.1f}%")
# Get shots with coordinates for visualization
for shot in shots.field_goals:
if shot.has_coordinates:
status = "Made" if shot.is_made else "Missed"
print(f"{shot.player}: {status} at ({shot.coord_x}, {shot.coord_y})")
# Filter by team, player, or zone
team_shots = shots.get_shots_by_team("MAD")
player_shots = shots.get_shots_by_player("P001")
paint_shots = shots.get_shots_by_zone("C")
# Analyze special situations
fastbreak_shots = [s for s in shots.field_goals if s.fastbreak]
second_chance = [s for s in shots.field_goals if s.second_chance]
Standings & Rankings
with EuroleagueClient() as client:
# Current standings
standings = client.v3.standings.basic("E", "E2025", round_number=20)
# Streak analysis
streaks = client.v3.standings.streaks("E", "E2025", round_number=20)
# Point differential margins
margins = client.v3.standings.margins("E", "E2025", round_number=20)
Async Support
For better performance with multiple requests:
import asyncio
from euroleague import AsyncEuroleagueClient
async def analyze_season():
async with AsyncEuroleagueClient() as client:
# Parallel requests
leaders, team_stats, standings = await asyncio.gather(
client.v3.player_stats.leaders_async("E", season_code="E2025"),
client.v3.team_stats.traditional_async("E", season_code="E2025"),
client.v3.standings.basic_async("E", "E2025", 20)
)
return leaders, team_stats, standings
asyncio.run(analyze_season())
API Versions
The Euroleague API has multiple versions and endpoints:
| Version | Focus | Best For |
|---|---|---|
| V1 | Legacy/Simple | Basic box scores, standings |
| V2 | Comprehensive | Clubs, games, people, seasons |
| V3 | Statistics | Player/team stats, analytics |
| Live | Real-time | Play-by-play, shot locations |
V1 Endpoints
client.v1.standings- League standingsclient.v1.games- Box scoresclient.v1.players- Player statsclient.v1.teams- Team rosters
V2 Endpoints
client.v2.clubs- Club informationclient.v2.games- Game details and historyclient.v2.people- Players, coaches, personnelclient.v2.seasons- Season informationclient.v2.standings- Detailed standings
V3 Endpoints (Recommended for Analytics)
client.v3.player_stats- Leaders, traditional, advanced, scoring statsclient.v3.team_stats- Traditional, advanced, opponent statsclient.v3.standings- Basic, streaks, margins, calendar viewsclient.v3.stats- Game stats, team comparisons
Live Endpoints (Real-time Game Data)
client.live.play_by_play- Play-by-play events with timestampsclient.live.shots- Shot locations with court coordinates
Competition Codes
E- EuroLeagueU- EuroCup
Examples
See the examples/ directory for complete working examples:
- basic_usage.py - Getting started with the API
- player_analysis.py - Player statistics and comparisons
- team_analysis.py - Team performance analysis
- game_analysis.py - Game results and box scores
- player_game_logs.py - Game-by-game player statistics
- fantasy_basketball.py - Fantasy basketball analysis
- async_example.py - Async client usage
- play_by_play_analysis.py - Play-by-play data analysis
- shot_chart_analysis.py - Shot location data with coordinates
Error Handling
from euroleague import EuroleagueClient
from euroleague.exceptions import NotFoundError, RateLimitError, APIError
with EuroleagueClient() as client:
try:
player = client.v2.people.get("INVALID_CODE")
except NotFoundError:
print("Player not found")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after}s")
except APIError as e:
print(f"API error: {e.message}")
License
MIT License - see LICENSE file for details.
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_euroleague-0.2.1.tar.gz.
File metadata
- Download URL: py_euroleague-0.2.1.tar.gz
- Upload date:
- Size: 26.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34ae53f352272b03b178ebd39c30faa660e8577596d08208cea8033aeb2d1bf4
|
|
| MD5 |
aefdd6600707a60775e27a7158fbbc80
|
|
| BLAKE2b-256 |
7c84fd92309773a4dc62fbecc59d4d68e234b2ebc915112db6983778ca0d6906
|
Provenance
The following attestation bundles were made for py_euroleague-0.2.1.tar.gz:
Publisher:
release.yml on sfendourakis/py-euroleague
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_euroleague-0.2.1.tar.gz -
Subject digest:
34ae53f352272b03b178ebd39c30faa660e8577596d08208cea8033aeb2d1bf4 - Sigstore transparency entry: 872122206
- Sigstore integration time:
-
Permalink:
sfendourakis/py-euroleague@9df9fb9353f1efe2d7956cade494336931abe43f -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/sfendourakis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9df9fb9353f1efe2d7956cade494336931abe43f -
Trigger Event:
push
-
Statement type:
File details
Details for the file py_euroleague-0.2.1-py3-none-any.whl.
File metadata
- Download URL: py_euroleague-0.2.1-py3-none-any.whl
- Upload date:
- Size: 48.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd9436e4913732806465affc5042a2e1cb8a3dca2442d151cf45dc66aed15b04
|
|
| MD5 |
d2c640eba116575d828e9f6c00bb040d
|
|
| BLAKE2b-256 |
375659763b7f9d2d278f63169ba36739114bae9d353dc7b310f07300ad608841
|
Provenance
The following attestation bundles were made for py_euroleague-0.2.1-py3-none-any.whl:
Publisher:
release.yml on sfendourakis/py-euroleague
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_euroleague-0.2.1-py3-none-any.whl -
Subject digest:
dd9436e4913732806465affc5042a2e1cb8a3dca2442d151cf45dc66aed15b04 - Sigstore transparency entry: 872122210
- Sigstore integration time:
-
Permalink:
sfendourakis/py-euroleague@9df9fb9353f1efe2d7956cade494336931abe43f -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/sfendourakis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9df9fb9353f1efe2d7956cade494336931abe43f -
Trigger Event:
push
-
Statement type: