Back to API-Sports in Google Sheets
SheetXAI logo
API-Sports logo
API-Sports · Google Sheets Guide

Dump a Full Head-to-Head Record Into Google Sheets for Win/Loss Analysis

2026-05-13
4 min read
See the Excel version →

The Scenario

You are a sports betting researcher. You have been asked to prepare a 10-year head-to-head analysis of Liverpool vs Manchester City for a client who bets on the rivalry fixture. The client wants every match between the two clubs across all competitions — Premier League, FA Cup, League Cup, Champions League — with date, competition, home score, and away score.

You have the API-Sports subscription. You do not want to spend the afternoon clicking through match history pages.

The bad version:

  • You look up the H2H endpoint in the docs and construct the URL with Liverpool's team ID (40) and Manchester City's team ID (50)
  • The response returns matches as a JSON array, each with a nested fixture object, nested teams object, and nested goals object
  • You write a script to flatten it
  • You run the script, get 47 matches, discover 11 of them predate 2015 and your client wants 10 years only
  • You filter by date in the script, rerun, export to CSV
  • The venue column is empty for historic fixtures before the API's data coverage expanded
  • You have been at this for an hour and the client wants it by 3 PM.

The faster version is one prompt.

The Easy Way: One Prompt in SheetXAI

SheetXAI is an AI agent inside your spreadsheet that calls the H2H endpoint and applies your filters and date constraints on the way in.

Open the SheetXAI sidebar and type:

Fetch all head-to-head fixtures between Liverpool and Manchester City for the last 10 years and list them in this sheet with date, competition, home team, away team, home score, and away score. Sort by date descending.

SheetXAI calls the API-Sports head-to-head endpoint, filters to the last 10 years, flattens the nested JSON, and writes the result as a clean table. Matches without venue data come through with the known fields intact and the venue column blank rather than erroring.

What You Get

A structured match history table:

  • Date — formatted as readable dates, not Unix timestamps
  • Competition — Premier League, FA Cup, League Cup, Champions League group stage, etc.
  • Home and away teams — with the direction of play clear for each fixture
  • Scoreline — home score and away score per match

The competition column lets you slice by tournament without any additional work. Your client can filter to Premier League only, or look at the cup form separately.

What If the Data Is Not Quite Ready

Head-to-head research usually involves more than a raw list of results. SheetXAI can do the aggregations and sub-analyses inline.

When you want win/draw/loss aggregates by competition

The match list is in the sheet but your client wants a summary: how many times did each team win in each competition type?

Count Liverpool wins, draws, and Manchester City wins from the match history in this sheet, grouped by the competition column. Write the summary into a new tab called 'H2H Summary' with one row per competition.

When the competition names are inconsistent

API-Sports sometimes returns "Premier League" and sometimes "England Premier League" depending on the data vintage. Your pivot table breaks on the inconsistency.

Standardise the competition names in column C so all Premier League entries read 'Premier League', all FA Cup entries read 'FA Cup', and all League Cup entries read 'League Cup'. Collapse any remaining variants into 'Other'. Write the corrected names in place.

When you want to filter to a specific manager era

Your client is interested only in the Klopp vs Guardiola head-to-head. Klopp took over Liverpool in October 2015 and left in May 2024.

Filter the match history to fixtures played between October 2015 and May 2024. Move those rows to a new tab called 'Klopp Era' and add a column showing the goal difference per match in Liverpool's favour (positive means Liverpool won by more).

When you want the full analysis for a betting brief in one pass

The client wants the raw match list, the aggregate summary by competition, a per-season win rate for each team, and a flag on matches where the total goals exceeded 3. All in one document.

Fetch all Liverpool vs Manchester City fixtures from the last 10 years with date, competition, home team, away team, home score, and away score. Write the raw list in the main tab. Create an 'H2H Summary' tab with Liverpool wins, draws, and City wins grouped by competition. Create a 'Season Breakdown' tab with each team's win count per season. Add a column to the main tab called 'High Scoring' that marks rows where total goals are 4 or more.

The pattern: instead of pulling the data and then building the analysis separately in pivot tables, you describe the full deliverable and SheetXAI runs the API call and the analytical breakdown together.

Try It

Get the 7-day free trial of SheetXAI and ask it to pull a head-to-head record for any fixture pair directly into your sheet. The API-Sports integration is included in every SheetXAI plan. For related workflows, see how to pull fixture lists and standings or the API-Sports in Google Sheets overview.

Stop memorizing formulas.
Tell your spreadsheet what to do.

Join 4,000+ professionals saving hours every week with SheetXAI.

Learn more