- What is xG in football and how does this metric help in transfer analytics
- How clubs use xG statistics when selecting and evaluating players
- Which sports event APIs provide access to xG data and advanced statistics
- How to connect and use the xG data API for club transfer analytics
- How to analyze forwards and midfielders using xG, xA, and other metrics through the API
- How to reduce the risks of unsuccessful transfers using xG and data from the API
- Examples of using xG and football statistics APIs in scouting and player selection
What is xG in football and how does this metric help in transfer analytics
xG (expected goals) is a numerical assessment of the quality of a goal-scoring opportunity. Each shot on goal is assigned a probability of resulting in a goal. The probability is calculated based on historical data: shot position, angle to the goal, type of pass, body part, pressure from defenders, and other factors. For example, a penalty typically has an xG of about 0.75–0.8, while a long-range shot from outside the penalty area has an xG of 0.02–0.05. The sum of xG for a match or season shows how many goals a team or player «should» have scored based on the quality of the chances created.
For transfer analytics, xG is fundamentally important because it separates the quality of play from the randomness of finishing chances. The number of goals scored heavily depends on luck over short periods, while xG is more stable and better describes the actual level of performance. Club recruitment departments evaluate forwards based on their xG and the «goals – xG» ratio to understand who consistently gets into scoring positions and who is experiencing a short-term spike. Similarly, defense is analyzed: the xG conceded by opponents reflects how often the team allows dangerous chances at their goal.
Data-driven clubs build long-term player value models where xG and related metrics (npxG, xG/90, xGChain, etc.) serve as the foundation. For accurate calculation and tracking of these metrics, detailed data on shots and team statistics is needed. This is where sports event APIs come into play: they allow for a single stream of matches, advanced statistics, live events, and bookmaker odds. Based on such data, one can create their own xG models and integrate them into transfer analytics, automating the evaluation of thousands of players from dozens of leagues.
How clubs use xG statistics when selecting and evaluating players
When evaluating forwards and attacking midfielders, clubs look not only at goals and assists but also at the player’s xG profile. The key question is: how often does the footballer get into quality scoring positions and how stable is this skill over time? Analysts compare xG/90 minutes, xG per shot, the share of shots from «hot zones,» and the dynamics of these metrics over several seasons. This allows distinguishing a player who scored 15 goals with an xG of 7 (likely overperformance, risk of regression to the mean) from a forward with 10 goals and an xG of 14 (creates many chances but is temporarily not converting them).
Transfer departments also use more nuanced analyses. For example, they calculate xG in various contexts: against strong opponents, when the score is level, in the last 15 minutes of the match. The structure of chances is analyzed by type of attack: quick breaks, positional attacks, set pieces. For creative midfielders, not only their own xG is important but also xA (expected assists), as well as involvement in building attacks (passes into the final third, pre-goal actions). All of this can be calculated automatically if match and event data come from a reliable sports statistics API.
Professional clubs build a comprehensive analytical pipeline: matches from the desired leagues are automatically loaded from the sports events API, along with statistics on shots and team actions, then xG and other metrics are calculated on top of this data, and rankings and player shortlists are built based on them. This approach reduces the subjectivity of scouting and allows for quickly finding undervalued players in markets where competitors are still relying only on traditional metrics.
Which sports event APIs provide access to xG data and advanced statistics
To work with xG at the club level, not only final scores and goal scorers are needed, but also detailed match statistics. Modern sports events APIs provide extensive data: overall and quarterly statistics, number and types of shots, possession, «big chances,» actions in the final third, and much more. These parameters serve as the foundation for building proprietary xG models. The richer and cleaner the raw data, the more accurate the assessment of the quality of created chances and the stability of player performances.
The platform api-sport.ru offers a unified Sport Events API for several sports, including football, basketball, hockey, tennis, table tennis, and esports. Through the endpoint /v2/football/matches you can obtain matches with an array matchStatistics, where key indicators are grouped by periods: shots, possession, passes, duels, and defensive actions. This data is used as input for the club’s own xG/xA models. Additionally, a block is available oddsBase with bookmaker odds, which allows for considering market expectations when assessing the strength of teams and players.
Integration with the API is straightforward: the club authenticates via an API key and requests the necessary tournaments, seasons, and matches, filtering data by leagues, teams, and match status. Then, the analytical system automatically extracts statistics and saves them in a data warehouse. Below is an example of a basic request to the football API, based on which the club’s xG model can be calculated:
const API_KEY = 'YOUR_API_KEY';
async function loadMatchesWithStats(date) {
const url = `https://api.api-sport.ru/v2/football/matches?date=${date}`;
const res = await fetch(url, {
headers: { 'Authorization': API_KEY }
});
const data = await res.json();
data.matches.forEach(match => {
// match.matchStatistics содержит детальную статистику,
// на основе которой можно считать xG-модель клуба
console.log(match.id, match.matchStatistics);
});
}
loadMatchesWithStats('2025-09-03');
How to connect and use the xG data API for club transfer analytics
Connecting to the Sport Events API for transfer analytics usually starts with registration and obtaining an access key. On the platform api-sport.ru it takes a few minutes: you create an account, choose a plan for the required volume of requests, and in the personal account. receive an API key. The key is then added to the header Authorization of each request. This approach ensures security and allows for flexible control of limits, and the club can divide keys by teams of analysts or by individual services within the infrastructure.
The next step is designing the data pipeline. Usually, the club needs: a list of supported sports and tournaments, then – matches from selected leagues over several seasons and their statistics. This can be implemented as a periodic batch retrieval (for example, loading updated matches once a day) or as an almost online stream, further supplemented by a WebSocket connection. After loading, the data goes into storage (SQL/NoSQL/columnar), where xG, xA, and derived metrics are calculated. The results are available to the recruiting department through internal dashboards and reports.
Below is an example of a simple Python script that retrieves the team’s matches, including statistics, and prepares data for calculating xG metrics:
import requests
API_KEY = 'YOUR_API_KEY'
BASE_URL = 'https://api.api-sport.ru/v2/football/matches'
params = {
'team_id': 195801, # ID команды
'status': 'finished' # только завершенные матчи
}
headers = {
'Authorization': API_KEY
}
response = requests.get(BASE_URL, params=params, headers=headers)
response.raise_for_status()
matches = response.json().get('matches', [])
for match in matches:
stats = match.get('matchStatistics', [])
# Здесь можно вызвать свою функцию расчета xG
# compute_xg_from_stats(stats)
print(match['id'], len(stats))
Then this code is expanded: loops for tournaments and seasons are added, raw data and xG calculation results are saved to the database, and integration with BI systems appears. As new opportunities arise (for example, WebSocket streaming of live events and AI models on the provider’s side), the club can enrich the pipeline and use xG in real-time – for live scouting and assessing player form dynamics.
How to analyze forwards and midfielders using xG, xA, and other metrics through the API
For forwards, key metrics are considered xG/90, the number of shots from the penalty area, the share of shots with high xG values, and the difference between «goals – xG». Using data obtained through the match API, the club can collect statistics for each player on shots, «big chances», touches in the penalty area, and possession in the final third. Based on these parameters, a model of expected goals is built. A player who consistently generates high xG even in average teams is usually better predicted than a forward with a single explosive season at low xG.
For creative midfielders, a block of passes and chance creation is added. Potential xA (how dangerous chances are created by the player’s passes), the number of passes into the final third, pre-goal actions, and pass accuracy under pressure are analyzed. The sports events API provides detailed team statistics such as finalThirdEntries, accuratePasses, «big chances created», as well as lineups and basic player statistics in lineup. By combining this data by matches, analysts build their models of expected assists and the player’s contribution to chance creation.
This is how a simplified process of aggregating player statistics by team matches using the API might look:
import requests
API_KEY = 'YOUR_API_KEY'
headers = {'Authorization': API_KEY}
# 1. Берем все завершенные матчи команды
matches = requests.get(
'https://api.api-sport.ru/v2/football/matches',
params={'team_id': 195801, 'status': 'finished'},
headers=headers
).json().get('matches', [])
player_stats = {}
for match in matches:
home = match['homeTeam']
away = match['awayTeam']
for team in (home, away):
lineup = team.get('lineup', {}).get('players', [])
for p in lineup:
pid = p['id']
st = p.get('statistics', {}) # содержит детализацию по игроку, если включена
player_stats.setdefault(pid, []).append(st)
# Далее клуб считает xG/xA для каждого игрока по своим моделям
In practice, complex reports are built on top of such aggregated data: xG distributions by timings, shot maps, contributions to pressing traps through duels and interceptions, comparisons with the player’s market value. By using a unified API as a source of raw data, the club gains flexibility: different xG/xA models can be tested and quickly updated without relying on the format of third-party ready-made metrics.
How to reduce the risks of unsuccessful transfers using xG and data from the API
Unsuccessful transfers are often associated with overestimating short-term results. A player may have a standout season, scoring many goals from difficult positions, but their xG may remain moderate. The analysis of «goals – xG» shows how statistically stable the current result is. If a forward scores significantly more than expected based on the quality of chances for a long time, there is a high risk of regression to the mean. A club that relies on xG analytics sees such patterns in advance and evaluates the player’s value and contract terms more cautiously.
The sports events API allows for the automation of this risk analysis. The club can build time series of xG and allowed xG for opponents for each potential target, taking into account the league context and team strength. An additional layer is the use of bookmaker odds data from the block oddsBase: they reflect the market expectation of team strength in each match. By comparing the actual xG profile of a player with how often their team was a favorite or underdog according to the odds, analysts adjust the evaluation: they highlight those who consistently create chances against strong opponents.
An example of obtaining odds for a match to further use them in the transfer risk model:
const API_KEY = 'YOUR_API_KEY';
async function loadMatchWithOdds(matchId) {
const res = await fetch(
`https://api.api-sport.ru/v2/football/matches/${matchId}`,
{ headers: { 'Authorization': API_KEY } }
);
const match = await res.json();
const odds = match.oddsBase || [];
// odds содержит рынки ставок (1X2, тотал и др.),
// их можно использовать как прокси силы команд
console.log(match.id, odds.map(m => m.group));
}
loadMatchWithOdds(14570728);
Based on such data, the club builds comprehensive scoring models: in addition to xG and xA, age, position, minutes played, tournament level, context of odds, and performance stability are taken into account. This reduces the likelihood of overpaying for a «one-season star» and helps find players with a stable xG profile who are likely to carry their productivity into a new championship.
Examples of using xG and football statistics APIs in scouting and player selection
The practical application of xG in scouting begins with setting a task. For example, the club is looking for a forward who can consistently generate 0.4–0.5 xG per 90 minutes in a league of similar level. Analysts use the API to select the necessary tournaments, download all matches from the last two to three seasons, and calculate the xG profile of forwards. Players with suitable xG/90 metrics, a high number of shots from the center of the penalty area, and an acceptable age make it to the preliminary shortlist. After that, scouts engage in video work and live viewings based on a specially selected list of candidates, rather than hundreds of names.
Another case is the search for a creative midfielder. The club forms a filter based on xA/90, the number of passes into the final third, «big chances created,» and compactness of ball losses. Data is taken from the Sport Events API: matches, lineups, advanced statistics on passes, possession, and actions in the final third. On top of these parameters, a model of expected assists is calculated. The output is a ranking of players that takes into account not only the actual count of assists (dependent on the forwards’ finishing) but also the quality of chances created.
Below is an example of how to start with a simple step: obtain a list of players from the team or league of interest, and then combine them with calculated xG/xA metrics in your system:
import requests
API_KEY = 'YOUR_API_KEY'
headers = {'Authorization': API_KEY}
# Получаем игроков конкретной команды (например, потенциальной цели для массового скаутинга)
resp = requests.get(
'https://api.api-sport.ru/v2/football/players',
params={'team_id': 195801},
headers=headers
)
resp.raise_for_status()
data = resp.json()
players = data.get('players', [])
for p in players:
print(p['id'], p['name'], p.get('position'))
# Далее по player_id можно подтягивать матчи и статистику,
# считать xG/xA и строить рейтинги для трансферного шорт-листа
By uniting similar scenarios into a single system based on the API of sports events, the club receives a scalable scouting infrastructure. It allows for quick responses to market changes, testing alternative xG models, utilizing new opportunities from the data provider (WebSocket for live events, AI assessments, additional sports) and establishing a unified analytics standard for the first team, academy, and farm clubs.




