# Tennis Player Stats & H2H Scraper — ATP, WTA Match History (`incognito_mode/tennis-player-stats-h2h-scraper`) Actor

Head-to-head records and full match history for any ATP, WTA, Challenger or ITF player from Sofascore. Give names, IDs or pairs like "Sinner vs Alcaraz": get every meeting, the tally by surface, and each player's results with scores, opponents and rankings. Optional serve stats and odds. No API key.

- **URL**: https://apify.com/incognito_mode/tennis-player-stats-h2h-scraper.md
- **Developed by:** [Elena Vance](https://apify.com/incognito_mode) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.50 / 1,000 tennis matches

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Tennis Player Stats & H2H Scraper — ATP, WTA Match History (Sofascore)

Get the **head-to-head record** between any two tennis players and the **match
history** of any player on the ATP, WTA, Challenger or ITF tour. Type names
like `Sinner vs Alcaraz` or `Iga Swiatek`. You get one row per match, told
from the player's side: opponent, won or lost, the score, sets and games,
surface, round and tournament. Each pair also gets a free summary row with the
overall tally and a split by surface.

No API key, no browser, no residential proxy. Export as **JSON, CSV, Excel,
XML or HTML**, or call it through the Apify API.

**$2.50 per 1,000 matches.** A full head-to-head usually costs under 5 cents.
See [Pricing](#pricing).

### What you get

`Sinner vs Alcaraz` on 2026-11-23 returned 18 meetings and this summary row:

| Field | Value |
| --- | --- |
| matchup | Jannik Sinner vs Carlos Alcaraz |
| totalMeetings | 18 |
| playerAWins / playerBWins | 7 / 11 |
| bySurface | hard 3–8, clay 2–3, grass 2–0 |
| lastMeeting | 2026-04-12, Monte Carlo final, Sinner won 7-6(5) 6-3 |

Every one of the 18 meetings is also its own row, numbered oldest first
(`meetingNumber` 1 is a 2019 Challenger in Alicante). Each row carries the
score from Sinner's side, the round, surface and tournament.
Add **Match statistics** to get aces, first-serve %, break points and more
for each meeting, or **Odds** for the opening and closing prices.

### What it's for

- **Betting research.** Get the head-to-head by surface before a match, with
  opening and closing odds for every past meeting.
- **Modelling.** Pull a player's whole career (about 700 matches for a top
  player) as one flat table: opponents, rankings, surfaces, scores, serve
  stats.
- **Content and tipping.** Show recent form, last-meeting scores and surface
  splits without copying them by hand.
- **AI agents and apps.** Plain array input (`players`, `matchups`) and flat
  rows, so an agent can call it directly.

### How to use it

**Head-to-head between two players:**

```json
{
  "matchups": ["Sinner vs Alcaraz"]
}
```

**A player's last 50 matches, plus serve stats:**

```json
{
  "players": ["Iga Swiatek"],
  "maxMatchesPerPlayer": 50,
  "matchDetails": ["statistics"]
}
```

**Several head-to-heads on clay over the last three years:**

```json
{
  "matchups": ["Sinner vs Alcaraz", "Djokovic vs Zverev", "Swiatek vs Sabalenka"],
  "surface": ["clay"],
  "dateFrom": "3 years"
}
```

**A whole career, tour-level only:**

```json
{
  "players": ["Novak Djokovic"],
  "maxMatchesPerPlayer": 0,
  "tourLevels": ["atp", "team"]
}
```

#### Tips

- **Names, IDs or links all work.** `Iga Swiatek`, `228272` and
  `https://www.sofascore.com/team/tennis/swiatek-iga/228272` are the same
  player. The run log shows who each name was matched to (`"Swiatek" → Iga
  Swiatek (228272)`), and every row keeps your text in `resolvedFrom`.
- **Use full names for shared surnames.** `Williams` picks Serena and logs a
  warning naming Venus. `Serena Williams` or the ID is unambiguous.
- **Filters are free.** Surface, tour level and dates are applied before
  anything is stored or charged.
- **`maxMatchesPerPlayer` counts after filters.** With Surface = grass, 50
  means the 50 most recent grass matches.

### Input

| Field | Default | Notes |
| --- | --- | --- |
| `players` | — | Names, Sofascore IDs or URLs. One row per finished singles match, newest first |
| `matchups` | — | `"A vs B"` (`v`, `-` and `x` work too). Every meeting plus a free summary row |
| `maxMatchesPerPlayer` | `50` | Per player, after filters. `0` = whole career. Pairs always return every meeting |
| `maxItems` | `1000` | Cap on match rows for the whole run. Summary rows don't count |
| `dateFrom` / `dateTo` | — | `YYYY-MM-DD` or relative (`1 year`, `6 months`) |
| `surface` | all | `hard`, `clay`, `grass`, `carpet` |
| `tourLevels` | all | `atp`, `wta` (incl. WTA 125), `challenger`, `itf`, `team` (Davis Cup, BJK Cup, United Cup) |
| `includeExhibitions` | `false` | Exhibitions and UTR events are left out unless you turn this on |
| `matchDetails` | — | `statistics`, `odds` (paid add-ons) |

You need at least one of `players` or `matchups`.

### Output

Two kinds of row share one dataset; tell them apart with `rowType`.

#### `rowType: "match"`, one per match (charged)

```jsonc
{
  "rowType": "match",
  "matchup": "Jannik Sinner vs Carlos Alcaraz", // null on player-history rows
  "meetingNumber": 18,                          // 1 = oldest meeting; null on player rows
  "perspectivePlayer": { "id": 206570, "name": "Jannik Sinner" },
  "opponent": { "id": 275923, "name": "Carlos Alcaraz", "country": "Spain", "countryCode": "ESP", "ranking": 3 },
  "won": true,
  "scoreForPlayer": "7-6(5) 6-3",   // from the perspective player's side
  "setsWon": 2, "setsLost": 0, "gamesWon": 13, "gamesLost": 9,
  "startTimeIso": "2026-04-12T13:00:00+00:00",
  "tour": "ATP",
  "tournamentName": "Monte Carlo",
  "round": { "name": "Final", "slug": "final", "number": 29 },
  "surface": "Red clay",
  "surfaceCategory": "clay",
  "resultType": "completed",         // or "retired", "walkover"
  "scoreString": "6-7(5) 3-6",       // home player first, as in our main tennis Actor
  "player1": { "...": "home player: id, name, country, ranking, seed" },
  "player2": { "...": "away player" },
  "sets": [{ "set": 1, "player1": 6, "player2": 7, "player1TieBreak": 5, "player2TieBreak": 7 }],
  "matchUrl": "https://www.sofascore.com/tennis/match/carlos-alcaraz-jannik-sinner#id:15921175",
  "resolvedFrom": "Sinner",
  "source": "matchup",               // or "player"
  "statistics": [ /* with Match statistics on */ ],
  "odds": [ /* with Odds on */ ]
}
```

`player1`/`player2`, `sets`, `statistics` and `odds` keep Sofascore's home/away
order, the same as in our
[main tennis Actor](https://apify.com/incognito_mode/sofascore-tennis-scraper),
so data from both joins on `eventId`. Use `perspectivePlayer`, `opponent`,
`won` and `scoreForPlayer` when you want the player's side.

#### `rowType: "h2h"`, one per pair (free)

```jsonc
{
  "rowType": "h2h",
  "matchup": "Jannik Sinner vs Carlos Alcaraz",
  "playerA": { "id": 206570, "name": "Jannik Sinner" },
  "playerB": { "id": 275923, "name": "Carlos Alcaraz" },
  "totalMeetings": 18,
  "playerAWins": 7,
  "playerBWins": 11,
  "bySurface": {
    "hard":  { "playerAWins": 3, "playerBWins": 8 },
    "clay":  { "playerAWins": 2, "playerBWins": 3 },
    "grass": { "playerAWins": 2, "playerBWins": 0 }
  },
  "lastMeeting": { "date": "2026-04-12", "tournament": "Monte Carlo", "surface": "clay", "winner": "Jannik Sinner", "score": "7-6(5) 6-3" },
  "filtered": false  // true when dates, surface or tour level narrowed the meetings
}
```

The tally is computed from the meeting rows in the same run, so the two always
agree. Retirements and walkovers count as a win for the player who went
through; their rows say so in `resultType`.

In Console, the **Matches** view shows the match columns and the
**Head-to-head** view shows the summary columns.

### Pricing

Pay per event. You pay only for match rows that are stored.

| Event | When it is charged | Price |
| --- | --- | ---: |
| Actor start | once per run | $0.00005 |
| Match | every stored match row | $0.0025 |
| Match statistics | match has statistics (add-on) | $0.001 |
| Odds | match has odds (add-on) | $0.001 |
| Head-to-head summary | every pair | **free** |

Examples:

- One head-to-head with 18 meetings ≈ **$0.05**
- A player's last 50 matches ≈ **$0.13**, or about **$0.23** with statistics
  and odds
- A top player's whole career (about 700 matches) ≈ **$1.75**

Matches removed by your filters are never charged. The run stops cleanly at
your maximum charge per run. If that cuts a pair short, its summary row is
left out rather than showing a partial tally.

### Ready-made examples

Open one, press **Try for free**, and change the input to your own.

- [Sinner vs Alcaraz head-to-head: every meeting, with stats](https://apify.com/incognito_mode/tennis-player-stats-h2h-scraper/examples/sinner-vs-alcaraz-head-to-head)
- [Novak Djokovic career match history: every tour-level match](https://apify.com/incognito_mode/tennis-player-stats-h2h-scraper/examples/novak-djokovic-career-match-history)
- [WTA top 5: the last 50 matches of each player](https://apify.com/incognito_mode/tennis-player-stats-h2h-scraper/examples/wta-top-players-last-50-matches)

### FAQ

**Is there a tennis head-to-head API?**
The official ATP and WTA feeds are licensed to bookmakers and broadcasters.
This Actor gives you head-to-heads and match history from Sofascore's public
data. You pay per match, with no subscription, and the Apify free plan's
monthly credit covers casual use.

**How do I use it from Python?**
With the `apify-client` package: start a run, then read the dataset into
pandas. The [tennis-h2h-python](https://github.com/arman-007/tennis-h2h-python)
example repo does a head-to-head, a player's form by surface and serve stats
in a few lines each, with a notebook and charts.

**Why did the same match appear twice?**
Each row is one match from **one player's side**. If you list both Sinner and
Alcaraz under `players`, their meetings come back once from each side, and
each row is charged. Typing the same player twice, or the same pair twice or
reversed, does *not* duplicate anything.

**I asked for 50 matches and got fewer.**
The player may have fewer matches that pass your filters (surface, dates,
tour level), or you reached `maxItems` or your maximum charge. The log says
which.

**Why is there no summary row for one of my pairs?**
Either the run stopped (at `maxItems` or your maximum charge) before all of
that pair's meetings were stored, or a name could not be found. The log names
the pair and the reason. A pair that has simply never met still gets a
summary row with `totalMeetings: 0`.

**Does the tally match the ATP or WTA website?**
By default it counts every competitive meeting Sofascore has: tour level,
Grand Slams, Challenger, ITF and team events, but not exhibitions. Official
sites can count differently, for example leaving out Challenger matches. Set
**Tour level** to match the count you follow.

**Are doubles supported?**
Not yet. Doubles pairs are separate Sofascore entities, so rows are singles
only, and a player's doubles matches are left out.

**Do I need a proxy?**
No. Requests go to Sofascore directly. If an IP is ever blocked, the Actor
switches to a datacenter proxy on its own.

**How should I use the data?**
You are responsible for using the data in line with Sofascore's terms and the
laws that apply to you.

### Related actors

- **[Tennis Scraper & API — ATP, WTA Stats, Point-by-Point, Odds](https://apify.com/incognito_mode/sofascore-tennis-scraper)**: every match by date or live, across all tours, with point-by-point and momentum.
- **[ATP & WTA Rankings Scraper](https://apify.com/incognito_mode/sofascore-rankings-scraper)**: full ATP, WTA, live and UTR ranking tables.
- **[Flashscore Tennis Scraper](https://apify.com/incognito_mode/flashscore-tennis-scraper)**: the same tours from Flashscore, as a second source.

# Changelog

This Actor's version history is a separate document: https://apify.com/incognito_mode/tennis-player-stats-h2h-scraper/changelog.md

# Actor input Schema

## `players` (type: `array`):

Players whose recent match history you want, one per line. Each line can be a full name ("Iga Swiatek"), a Sofascore player ID ("206570") or a Sofascore player URL ("https://www.sofascore.com/team/tennis/sinner-jannik/206570"). Full names are safest: a surname shared by two players ("Zverev") picks the more followed one and logs a warning. Returns one row per finished singles match, newest first.

## `matchups` (type: `array`):

Pairs to compare, one per line, written "Player A vs Player B" ("v", "-" and "x" also work, with spaces around them). Each side accepts a name, ID or URL like "Players". Returns every finished meeting between the two, from player A's side, numbered oldest first, plus one free summary row (rowType "h2h") with the overall and per-surface tally.

## `maxMatchesPerPlayer` (type: `integer`):

How many of each player's most recent matches to return, counted after the filters below (so 50 with Surface = grass is the 50 most recent grass matches). 0 returns the whole career, up to about 700 matches for a top player. Does not limit head-to-head pairs, which always return every meeting.

## `maxItems` (type: `integer`):

Hard cap on match rows stored (and charged) across the whole run. Head-to-head summary rows are free and not counted. If the cap cuts a pair short, that pair's summary row is left out rather than showing a partial tally.

## `dateFrom` (type: `string`):

Only matches on or after this date: YYYY-MM-DD, or relative such as "1 year" or "6 months" (counted back from today). Applies to player history and to head-to-head pairs.

## `dateTo` (type: `string`):

Only matches on or before this date (inclusive), same formats as "From date".

## `surface` (type: `array`):

Keep only matches on these surfaces. Empty = all surfaces.

## `tourLevels` (type: `array`):

Keep only these levels. Empty = all of them: ATP, WTA, Challenger, ITF and team events (exhibitions are controlled separately below). For a tour-level-only head-to-head, choose ATP or WTA plus Team events.

## `includeExhibitions` (type: `boolean`):

Exhibitions and UTR events are left out by default because they are not competitive tour matches. Turn on to include them.

## `matchDetails` (type: `array`):

Extra data per match, one request each. Statistics: serve, return, points and games per player for the match and each set. Odds: opening and closing decimal odds for match winner, first set and total games. Charged only for matches where Sofascore has the data.

## `proxyConfiguration` (type: `object`):

Leave off. Requests go to Sofascore directly, which costs nothing. If an IP is blocked, the Actor switches on its own to a datacenter proxy (in every Apify plan) and only then to residential. Set this only to pin a specific proxy from the start.

## Actor input object example

```json
{
  "players": [
    "Jannik Sinner"
  ],
  "matchups": [
    "Sinner vs Alcaraz"
  ],
  "maxMatchesPerPlayer": 20,
  "maxItems": 1000,
  "surface": [],
  "tourLevels": [],
  "includeExhibitions": false,
  "matchDetails": [],
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `dataset` (type: `string`):

Match rows (rowType "match") and head-to-head summaries (rowType "h2h").

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "players": [
        "Jannik Sinner"
    ],
    "matchups": [
        "Sinner vs Alcaraz"
    ],
    "maxMatchesPerPlayer": 20,
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("incognito_mode/tennis-player-stats-h2h-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "players": ["Jannik Sinner"],
    "matchups": ["Sinner vs Alcaraz"],
    "maxMatchesPerPlayer": 20,
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("incognito_mode/tennis-player-stats-h2h-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "players": [
    "Jannik Sinner"
  ],
  "matchups": [
    "Sinner vs Alcaraz"
  ],
  "maxMatchesPerPlayer": 20,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call incognito_mode/tennis-player-stats-h2h-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,incognito_mode/tennis-player-stats-h2h-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/eItftHjUdTHvFKeET/builds/bLiubvL4eg6EZlCXy/openapi.json
