What is xG?
Expected goals is the probability that a shot becomes a goal, expressed as a number between 0 and 1. A penalty is around 0.76; a header from six yards is high; a shot from 30 metres is a few hundredths. Sum a team's shot values and you have the scoreline the chances deserved rather than the one it got.
It is a probability, not a rating
The number answers one question: given everything known about this shot at the moment it was taken, how often does a shot like it go in? It is not a judgement about the shooter, and it is not adjusted for the scoreline. A tap-in from three metres is worth roughly 0.9 whoever is standing there, which is exactly the point — the model is describing the chance, not the player.
Because it is a probability, xG adds. Two shots at 0.1 are worth 0.2 between them, and a match total is simply the sum of its shots. That property is what makes it usable as a team metric: 2.4 xG from 17 shots and 0.9 xG from 17 shots describe very different performances from the same shot count.
What goes into a model
A model is trained on a large set of historical shots, each labelled with whether it scored. Every shot becomes a feature vector — distance and angle to the goal, body part, whether it was a header, the type of assist, the phase of play, how many defenders were between the ball and the goal — and the training finds the combination of weights that separates goals from non-goals best.
Modern models are not one equation. Gradient-boosted trees or a neural network usually outperform a hand-fit logistic curve, and the difference shows up in the tails: long-range shots and crowded-box scrambles are where simple geometry models are weakest.
Why two providers disagree
Every provider trains on its own shot sample and picks its own features, so totals are not interchangeable. If one model was trained on a league with more long shots, it may rate them lower; if another includes defender positions from the event feed, it may rate blocked shots differently. Adding 1.2 xG from one source to 0.6 from another produces a number that means nothing.
This is the single most common mistake in football analytics work: mixing sources across seasons. Pick one, label it, and stay with it.
Getting xG from the API
Every shot carries `expected_goals` and `expected_goals_on_target`, plus the coordinates needed to draw it. Team totals come from the match stats endpoint, and `npxg` there is the same total with penalties removed — worth using when comparing teams, because a penalty is won rather than created.
curl https://api.pitchapi.dev/v1/matches/m_B8x2K9/shots \
-H "X-API-KEY: $PITCH_KEY"
# each shot: expected_goals, expected_goals_on_target,
# x, y, goal_line_x, goal_line_yReading it honestly
Over one match xG is noisy: a team can generate 2.5 and lose. Over ten matches the total starts to say something, and over a season it is one of the more stable performance measures available. The useful comparison is xG against goals over a run of matches, not over one — the gap between them is the signal.
xG also says nothing about the quality of a defensive structure. A side that concedes few shots can have a low xG against and still be organised badly; it just has not been punished yet. Treat it as one column in a table, not the verdict.
Keep reading
Read the number from the API
One key covers every competition and every endpoint, with 15,000 requests a day, no card, and the current season plus the one before it.