- What is xThreat (xT) in football and how does it measure attacking threat
- How the xThreat model works: calculation principle and key parameters
- How xThreat differs from xG and other football analytics metrics
- What data is needed to calculate xThreat and how to obtain it through sports event APIs
- How to use a football API to extract match events and attack coordinates
- How to build and configure your own xThreat model based on API data
- Application of xThreat analytics for evaluating team and player effectiveness
What is xThreat (xT) in football and how does it measure attacking threat
xThreat (xT, Expected Threat) is an advanced metric in football analytics that assesses how each action with the ball increases the likelihood of a goal. Unlike traditional statistics that only record shots and goals scored, xT looks at the entire path of the ball: passes, clearances, wing advances, entries into the penalty area. Each movement of the ball from one area of the field to another has a certain «threat value,» expressed in the probability that the team will finish the attack with a goal in the next few actions.
Technically, the field is divided into a grid of areas, and for each, the basic danger of ball possession at that point is calculated. When a player moves the ball from a less dangerous zone to a more promising one, they «create» an increase in xT. The sum of these increases over a match shows how much the team or a specific player advanced the game towards a goal, even if there were few shots. This approach is especially useful for assessing the hidden work of playmakers, full-backs, and players who rarely shoot on goal but constantly advance the ball forward.
For practical use of xThreat, large datasets about matches are required: events, timings, statistics, betting odds. That is why the metric works well with API of sports events and odds API-Sport. Through a standardized API, data on football and other sports can be automatically collected, custom attack threat models can be built, and integrated into betting applications, analytical dashboards, scouting, and media projects.
How the xThreat model works: calculation principle and key parameters
The basic principle of xThreat relies on dividing the football field into a grid (usually from 12×8 to 16×12 cells). For each cell, based on historical data, the probability is assessed that ball possession in this zone will ultimately lead to a goal in the next few actions (for example, during the next attack). This probability is the «threat» of the cell. When the ball moves from one cell to another, the difference in threat is calculated: if the team moved the ball to a more dangerous zone, it received a positive xT gain; if it lost the ball or moved it back, xT decreases or remains the same.
The model is built on a large dataset of historical matches, where for each possession, the sequences of actions, their timing, and outcomes (goal/no goal) are known. Based on these chains, transition probabilities between zones and the final chance of scoring are assessed. The more accurate and detailed the initial data, the more reliable the model. In real projects, xT often adds context: match score, minute, tournament, strength of opponents. These parameters are easily obtained from the Sport Events API: match status, field currentMatchMinute, tournament, category, statistics by periods — all this is available through a single interface.
In applied development, xT is often calculated «on the fly» for live matches. For example, your system requests data on the current match through the sports API, processes possession events, and recalculates the threat after each phase of the attack. This approach allows for building live dashboards, assessing dominance by xT instead of ball possession, and using xThreat as an additional signal for your own betting pricing models or evaluating coaching decisions.
How xThreat differs from xG and other football analytics metrics
xG (Expected Goals) assesses the probability of a goal from a specific shot on target, taking into account position, type of shot, body part, and other factors. This is a powerful but point metric: it indicates how quality the moments created by the team are. xThreat, on the other hand, analyzes the entire attacking phase, not just the finishing shot. It measures how the team moved the ball across the field and how much its actions brought them closer to a goal, even if it did not lead to a shot. Therefore, xT is particularly useful for analyzing attack construction and ball progression.
Unlike classic xG, xThreat allows for dividing player contributions into several types: those who raise the threat through ball progression (progressive passes, clearances, dribbles) and those who convert chances. For example, a midfielder who regularly advances the ball into the area in front of the penalty box will have a high total xT, even if they rarely shoot on goal. Meanwhile, a forward with a high number of shots has a high xG but does not necessarily generate a significant increase in threat in the early stages of the attack.
Compared to other metrics — such as xA (expected assists) or passing progression metrics — xThreat provides a more holistic view of possession. It takes into account not only the final passes but also the entire path of the ball. This makes xT particularly valuable in conjunction with bookmaker analytics: across the field oddsBase in the Sport Events API, you can obtain odds and analyze how changes in total xThreat during the match correlate with market dynamics. This approach is useful for both professional betting models and high-level media content.
What data is needed to calculate xThreat and how to obtain it through sports event APIs
For accurate calculation of xThreat, three main data blocks are required: a detailed timeline of ball possession events, information about the match itself, and, if possible, the coordinates of actions on the field. Ideally, you have a sequence of «player — type of action — time — area of the field — outcome of the attack.» Based on the historical array of such episodes, a threat model is built for each area and a transition matrix between them. These same rules are then applied to live matches.
The Sport Events API on the side API-Sport provides structured data on matches sufficient for building practical xT analytics. Through the endpoint /v2/football/matches you receive lineups, score, current minute (currentMatchMinute), detailed statistics by periods in the array matchStatistics and odds markets in oddsBase. The chronology of key match episodes (goals, cards, substitutions, penalties, VAR, etc.) can be exported via /v2/football/matches/{matchId}/events. This data gives you a timeline and context, and you can store the coordinates of actions in your tracking system and synchronize them with the timing of events.
Below is an example of a request for detailed information about the match and its statistics, which can be used as input for the xThreat model:
curl -X GET "https://api.api-sport.ru/v2/football/matches/14570728" \ -H "Authorization: YOUR_API_KEY" | jq
The response contains fields liveEvents и matchStatistics, based on which attacking phases (passes, entries into the final third, shots) can be identified and the level of pressure on the opponent can be assessed even without exact coordinates. In combination with your player and ball tracking system, this will allow you to build a complete xThreat model and scale it across dozens of leagues and seasons.
How to use a football API to extract match events and attack coordinates
A typical workflow for calculating xThreat revolves around two data streams: events from the football API and coordinates from the tracking system. Through the endpoint /v2/football/matches/{matchId}/events in the Sport Events API, you receive an ordered list of key episodes: goals, cards, penalties, substitutions, extra time, etc. These events contain the time in minutes, the team, and the type of action, which allows you to accurately link them to your coordinate data stored in a separate database or coming from an external tracking provider.
In practice, you build a unique episode identifier: for example, a combination of the match ID, minute, and event ordinal number. The event stream from the Sport Events API becomes the «backbone» of the timeline, while the coordinate stream complements it with the exact location of the ball and players for calculating transitions between areas of the field. This design does not require changes to the API itself and allows for the reuse of the same infrastructure for different leagues and seasons. Importantly, through the field status of the match and currentMatchMinute you always understand what phase the game is in and which events can already be safely processed.
An example of obtaining a list of match events, which are then linked to coordinates in your analytics system:
curl -X GET "https://api.api-sport.ru/v2/football/matches/14570728/events" \ -H "Authorization: YOUR_API_KEY" | jq
In the response, you will see fields время, type, команда, and the score after the event. This data allows for the separation of possessions, marking the beginnings and ends of attacks, and assessing where on the timeline the xThreat of the team grew the most. To obtain your own API key and set up automatic data export, simply register in your personal account. app.api-sport.ru and connect the necessary sports.
How to build and configure your own xThreat model based on API data
Building your own xThreat model can conveniently be broken down into several stages. First, you form a set of historical matches using the Sport Events API: you select tournaments and seasons through the tournament endpoints, obtain a list of matches, and then their detailed data and events. Next, you define the division of the field into a grid (for example, 16×12), where each cell reflects a specific zone. For each ball possession, you reconstruct the sequence of transitions between zones and record whether it ended in a goal. This dataset is used to train a model that assesses the probability of a goal from each cell and the value of transitions between them.
Algorithmically, this can be a simple empirical estimate (the frequency of goals after possessions started in a specific zone) or more complex approaches: logistic regression, gradient boosting, neural networks. An important detail is the consideration of context: match time, score, meeting status, opponent strength. These parameters can be conveniently taken from the responses of the Sport Events API. After obtaining a map of the basic xThreat across the field, you move on to the online part: for each new possession in a live match, you calculate the increase in threat with each ball advancement and aggregate it by teams and players.
Below is a conditional example of processing a match in Node.js: we download events and statistics, after which we pass them to our own xT calculation module:
const fetch = require('node-fetch');
async function loadMatch(matchId) {
const res = await fetch(`https://api.api-sport.ru/v2/football/matches/${matchId}`, {
headers: { Authorization: 'YOUR_API_KEY' }
});
const match = await res.json();
const evRes = await fetch(`https://api.api-sport.ru/v2/football/matches/${matchId}/events`, {
headers: { Authorization: 'YOUR_API_KEY' }
});
const events = await evRes.json();
// Здесь вы связываете events с координатами и считаете xThreat
// calculateXT(match, events, trackingData)
}
Such architecture allows for easy fine-tuning of the model: changing the grid size, adding new features, updating threat assessments as data accumulates. And when the API-Sport platform introduces WebSocket subscriptions and built-in AI modules, you will be able to calculate xThreat in real time without extra load on the infrastructure.
Application of xThreat analytics for evaluating team and player effectiveness
xThreat opens up a wide range of practical scenarios for clubs, betting companies, media, and developers of analytical services. Club analytics receives an objective tool for assessing playing style and the contribution of players to ball advancement: it is possible to build rankings based on total xT, on the increase in threat over 90 minutes, and on the role in the beginning of attacking phases. Scouting can select players who consistently raise the threat in the final third, even if their classic metrics (goals and assists) are not yet noticeable.
In betting, xThreat is useful as a source of independent signals about dominance. Instead of crude metrics like shots and ball possession, one can observe how the total xT of teams changes throughout the match and compare this with market dynamics, which you obtain through the field oddsBase in the Sport Events API. If the market odds have not yet fully reflected the advantage in threat, this can create additional opportunities for algorithmic strategies. Media platforms use xT to visualize the «hidden picture» of the match: threat heat maps, xThreat timeline graphs, individual player impact maps.
The integration of all these scenarios is simplified by a unified interface. API of sports events and odds. With one API key, you get football, hockey, basketball, tennis, and other sports, as well as access to bookmaker data. This allows you to build cross-sport threat models, test ideas in different leagues, and scale solutions without changing the back-end architecture. By registering in your personal account and connecting the necessary products, you can turn xThreat analytics into the foundation of your own professional services and B2B solutions.




