Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for statsbomb api via statsbombpy #263

Open
Alek050 opened this issue Nov 25, 2024 · 0 comments
Open

Add support for statsbomb api via statsbombpy #263

Alek050 opened this issue Nov 25, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@Alek050
Copy link
Owner

Alek050 commented Nov 25, 2024

Right now, we do not inherintly support the use of the StatsBomb api, but only those of .json files. This issue will focus on creating a solution for that in the future.

For those who want to use the api right now:

  • install statsbombpy: pip install statsbombpy
  • import statsbombpy: from statsbombpy import sb
  • set credentials: see authentication statsbombpy
  • obtain and save the raw files by using fmt="dict":
match_info = sb.matches(competition_id=9, season_id=42, fmt="dict")
lineup_info = sb.lineups(match_id=303299, fmt="dict")
events = sb.events(303299, fmt="dict")
  • save the files as json:
import json
files = {"match_info": match_info, "lineup_info": lineup_info, "events": events}
for file, data in files.items():
    with open(file, "w") as fp:
        json.dump(data , fp) 
  • load in the match object using DataBallPy:
from databallpy import get_match

match = get_match(
    event_data_loc="events.json",
    event_match_loc="match_info.json",
    event_lineup_loc="lineup_info.json",
    event_data_provider="statsbomb",
)
@Alek050 Alek050 added the enhancement New feature or request label Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant