Getting started#

Installation#

Before using the SkillcornerClient, you need to install it:

pip install --upgrade skillcorner

Now you need to set up your Skillcorner credentials by adding the following variables to your environment:

  • SKILLCORNER_USERNAME: Your username

  • SKILLCORNER_PASSWORD: Your password

How to use it#

You can instantiate the SkillcornerClient class like so:

from skillcorner.client import SkillcornerClient

client = SkillcornerClient()

Alternative#

If you don’t want to set those environment variables you will need to provide your username and password at instantiation. We strongly recommend using environment variables or any other way to avoid having your password in your code.

import os
from skillcorner.client import SkillcornerClient

secret_password = os.getenv('MY_PASSWORD_ENV_VAR')
client = SkillcornerClient(username='myusername', password=secret_password)

Examples#

Seasons#

Get and print seasons data

seasons = client.get_seasons()
pprint(seasons)

Competitions#

Get and print competition data for season 2023-2024 (season id 28)

competitions = client.get_competitions(params={'season': 28})
pprint(competitions)

Save competition data to a file

client.save_competitions(filepath='competitions_23_24.json', params={'season': 28})

Competition editions#

Get and print competition editions for FRA Ligue 1 (competition id 3)

competition_editions = client.get_competition_editions(competition_id=3)
pprint(competition_editions)

Save competition data to a file

client.save_competition_editions(competition_id=3, filepath='competition_editions_FRA_Ligue_1.json')

We can also filter on the season using the ‘params’ parameter

competition_editions = client.get_competition_editions(competition_id=3, params={'season': 28})
pprint(competition_editions)

Matches#

Get and print matches for FRA Ligue 1 2023-2024 (competition edition id 548)

matches = client.get_matches(params={'competition_edition': 548})
pprint(matches)

Save matches to a file

client.save_matches(filepath='matches_FRA_Ligue_1_2023_2024.json', params={'competition_edition': 548})

Match data#

Get and print match data for FRA Ligue 1 2023-2024 - Clermont Foot vs AS Monaco (match id 1023377)

match_id = 1023377
match_data = client.get_match(match_id=match_id)
pprint(match_data)

Save match data to a file

client.save_match(match_id=match_id, filepath=f'match_data_{match_id}.json')

Match Tracking Data#

Get and print match tracking data (if you have access to the match tracking data API)

match_id = 1023377  # FRA Ligue 1 2023-2024 - Clermont Foot vs AS Monaco
match_tracking_data = client.get_match_tracking_data(match_id=match_id)
pprint(match_tracking_data[10000:11000])  # print only the tracking data for frames 10000 to 11000

Save match tracking data to a file

client.save_match_tracking_data(match_id=match_id, filepath=f'match_tracking_data_{match_id}.jsonl')

Physical Data#

Get and print physical data for FRA Ligue 1 2023-2024 - OGC Nice (team id 70)

physical_data = client.get_physical(params={'season': 28, 'team': 70})
pprint(physical_data)

Save physical data to a file

client.save_physical(filepath='physical.json', params={'season': 28, 'team': 70})

In Possession Data#

Get and print off-ball running data for FRA Ligue 1 2023-2024 (competition edition id 548)

off_ball_runs = client.get_in_possession_off_ball_runs(params={'competition_edition': 548})
pprint(off_ball_runs)

Get and print passing data for FRA Ligue 1 2023-2024 (competition edition id 548)

passes = client.get_in_possession_passes(params={'competition_edition': 548})
pprint(passes)

Get and print overcoming pressure run data for FRA Ligue 1 2023-2024 (competition edition id 548)

pressure_received = client.get_in_possession_on_ball_pressures(params={'competition_edition': 548})
pprint(pressure_received)

Dynamic Events#

Get file-like object containing off-ball runs events for 2024-03-31 Manchester City Vs Arsenal match (match id 1463739)

match_id = 1463739
off_ball_run_events = client.get_dynamic_events_off_ball_runs(match_id=match_id, params={'file_format':'csv'})

Save off-ball runs events CSV file for 2024-03-31 Manchester City Vs Arsenal match (match id 1463739)

match_id = 1463739
client.save_dynamic_events_off_ball_runs(match_id=match_id,
                                         filepath=f'{match_id}_off_ball_runs.csv',
                                         params={'file_format':'csv'})

Save off-ball runs events Sportscode XML file for 2024-03-31 Manchester City Vs Arsenal match (match id 1463739)

match_id = 1463739
client.save_dynamic_events_off_ball_runs(match_id=match_id,
                                         filepath=f'{match_id}_off_ball_runs.xml',
                                         params={'file_format':'sportscode-xml'})

Save off-ball runs events Focus JSON file for 2024-03-31 Manchester City Vs Arsenal match (match id 1463739)

match_id = 1463739
client.save_dynamic_events_off_ball_runs(match_id=match_id,
                                         filepath=f'{match_id}_off_ball_runs.json',
                                         params={'file_format':'focus-json'})

Teams#

Get and print teams for FRA Ligue 1 2023-2024 (competition edition id 548)

teams = client.get_teams(params={'competition_edition': 548})
pprint(teams)

Save team data

client.save_teams(filepath='teams_FRA_Ligue_1_2023_2024.json', params={'competition_edition': 548})

Get and print team data for OGC Nice (team id 70)

team_id = 70
team_data = client.get_team(team_id=team_id)
pprint(team_data)

Save team data

client.save_team(team_id=team_id, filepath=f'team_{team_id}.json')

Players#

Get and print players

players = client.get_players(params={'search': 'barcola'})
pprint(players)

Get and print player data

player_id = 68485
player_data = client.get_player(player_id=player_id)
pprint(player_data)

Save player data

client.save_player(player_id=player_id, filepath=f'player_{player_id}.json')