Menu

How do I make a Premier League xG shot map in Python?
📰

How do I make a Premier League xG shot map in Python?

DEV Community: datascience·noah·3 days ago
#utH5NwrA
#devtodatascience#science#devto#dev#shots
Reading 0:00
15s threshold

Every located shot a club took in a season, with player, outcome, body part, expected goals and pitch coordinates, plus totals by zone.

Code verified October 10, 2026. It takes one call to get_shot_map, 10 credits.

The call

team takes an abbreviation, a name or an id from list_teams. Season 2025 is 2025-26. Pass against: true to see the shots a club conceded.

import requests import pandas as pd

API_KEY = " YOUR_API_KEY "

resp = requests . post ( " https://mcp.strikerapi.com/v1/get_shot_map " , headers = { " x-api-key " : API_KEY }, json = { " team " : " ARS " , " season " : 2025 , }, timeout = 60 , ) resp . raise_for_status () data = resp . json ()[ " data " ]

shots = pd . DataFrame ( data [ " shots " ]) print ( data [ " totals " ]) print ( pd . DataFrame ( data [ " zones " ])[[ " zone " , " shots " , " goals " , " xg " , " conversion " ]]) by_player = shots . groupby ( " player " ). agg ( shots = ( " xg " , " count " ), xg = ( " xg " , " sum " ), goals = ( " outcome " , lambda s : ( s == " goal " ).…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.