# Tennis Rankings Scraper — ATP & WTA Rankings (`khadinakbar/tennis-rankings-scraper`) Actor

Scrape current ATP (men's) and WTA (women's) world tennis rankings: rank, previous rank, rank change, points, player name, age and country. Pulls the full official top-150 per tour from ESPN's public JSON API. HTTP-only, MCP-ready.

- **URL**: https://apify.com/khadinakbar/tennis-rankings-scraper.md
- **Developed by:** [Khadin Akbar](https://apify.com/khadinakbar) (community)
- **Categories:** News, Automation
- **Stats:** 1 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 ranking records

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Tennis Rankings Scraper — ATP & WTA Rankings

Tennis Rankings Scraper pulls the current world rankings for both the **ATP** (men's) and **WTA** (women's) professional tennis tours, straight from ESPN's public JSON API. Each run returns one record per player with rank, previous rank, rank change, points, player name, age and country. It is HTTP-only, needs no API key or login, and is MCP-ready for structured JSON output.

### Best fit and connected workflows

Use this Actor when your workflow needs an up-to-date, machine-readable view of the world's top tennis players.

Common routing patterns:

- **ATP + WTA in one run** — the full official top-150 for both tours as a single dataset.
- **Single tour** — just men's or just women's rankings.
- **Top-N only** — cap `maxResultsPerTour` to keep just the top 10, 50, etc. to save on billing.
- **Rich player rows** — `includeAthleteDetails` adds age, birthplace, headshot and the ESPN player URL.

The output is a clean flat table that works well for dashboards, podcasts, sports-alert services, research pipelines, and AI agent workflows that need a dependable rankings tool call with a simple dataset readback.

### Practical scenario

An analyst named Priya wants this week's ATP top 50 for a client briefing. She sets `tours` to `['atp']`, `maxResultsPerTour` to `50`, and `maxResults` to `50`. The dataset returns rows like `{ rank: 1, playerName: 'Jannik Sinner', points: 13450, country: 'Italy', rankChange: 0 }`, which she drops straight into a slide. Runs every Monday, she gets a fresh, citable rankings table with no API key or scraping setup.

### Input

| Field | Type | Purpose |
|---|---:|---|
| `tours` | array | Tours to scrape: `atp`, `wta`, or both. Defaults to both. |
| `maxResultsPerTour` | integer | Cap on player records per tour, in rank order. Defaults to 150 (full list). |
| `maxResults` | integer | Global cap on billable player records for the run. Defaults to 300. |
| `includeAthleteDetails` | boolean | Add extended fields (age, birthplace, headshot, player URL). Defaults to true. |
| `proxyConfiguration` | object | Optional proxy. Not needed by default; ESPN's rankings API is public. |

#### Focused JSON example

```json
{
    "tours": ["atp", "wta"],
    "maxResultsPerTour": 150,
    "maxResults": 300,
    "includeAthleteDetails": true
}
```

### Output

Each dataset record is one player ranking row. Key fields:

| Field | Type | Meaning |
|---|---:|---|
| `tour` | string | `atp` or `wta` |
| `tourName` | string | Human tour name |
| `rank` | integer | Current world ranking position (1 = No. 1) |
| `previousRank` | integer | Previous ranking position |
| `rankChange` | integer | Movement (+N up, -N down, 0 held) |
| `trend` | string | `up`, `down`, or `same` |
| `points` | number | Ranking points |
| `playerId` | string | Stable ESPN player identifier |
| `playerName` | string | Player display name |
| `firstName` / `lastName` | string | Split player name |
| `country` / `countryCode` | string | Full country name and ISO alpha-3 code |
| `age` / `birthPlace` | integer / string | Player age and birthplace (when `includeAthleteDetails`) |
| `headshotUrl` / `playerUrl` | string | Headshot image and ESPN player page (when `includeAthleteDetails`) |
| `scrapedAt` | string | ISO 8601 UTC scrape timestamp |

Example record:

```json
{
    "tour": "atp",
    "tourName": "ATP (men)",
    "rank": 1,
    "previousRank": 1,
    "rankChange": 0,
    "trend": "same",
    "points": 13450,
    "playerId": "3623",
    "playerName": "Jannik Sinner",
    "firstName": "Jannik",
    "lastName": "Sinner",
    "country": "Italy",
    "countryCode": "ITA",
    "age": 24,
    "birthPlace": "San Candido, Italy",
    "headshotUrl": "https://a.espncdn.com/i/headshots/tennis/players/full/3623.png",
    "playerUrl": "https://www.espn.com/tennis/player/_/id/3623/jannik-sinner",
    "scrapedAt": "2026-08-17T14:00:00.000Z"
}
```

### Pricing

This Actor is **pay-per-event** (usage pass-through):

- **Actor start** — a small fixed charge per run, scaled by allocated RAM.
- **Ranking record** — charged once per player row delivered to the dataset.

Browse results for free on the dataset preview; you only pay per record you actually keep.

### Limitations

- Rankings reflect the latest snapshot ESPN publishes; there can be a short lag after ranking releases.
- The published list is the top 150 per tour. `maxResultsPerTour` therefore caps at 150.

# Actor input Schema

## `tours` (type: `array`):

Which tours to scrape. Choose 'ATP' (men's), 'WTA' (women's), or both. Defaults to both.

## `maxResultsPerTour` (type: `integer`):

Hard cap on billable player records produced per tour, in rank order (1 = world No. 1). Protects your budget. Defaults to 150 (the full published list). Set lower to keep only the top N.

## `maxResults` (type: `integer`):

Global hard cap on billable player records produced this run across all selected tours. Defaults to 300 (150 per tour x 2).

## `includeAthleteDetails` (type: `boolean`):

Add extended player fields (age, birth place, headshot URL, ESPN player URL) to each record. Defaults to true for a richer dataset. Turn off to keep rows lean.

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

Proxy settings. Defaults to no proxy; the ESPN rankings API is public and does not need one. Set only if you start seeing blocks.

## Actor input object example

```json
{
  "tours": [
    "atp",
    "wta"
  ],
  "maxResultsPerTour": 50,
  "maxResults": 300,
  "includeAthleteDetails": true
}
```

# Actor output Schema

## `players` (type: `string`):

Player ranking records produced by the run, one per player.

## `summary` (type: `string`):

Detailed terminal diagnostics and billing counters.

## `output` (type: `string`):

Stable machine-readable terminal outcome and delivery counters.

# 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 = {
    "tours": [
        "atp",
        "wta"
    ],
    "maxResultsPerTour": 50
};

// Run the Actor and wait for it to finish
const run = await client.actor("khadinakbar/tennis-rankings-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 = {
    "tours": [
        "atp",
        "wta",
    ],
    "maxResultsPerTour": 50,
}

# Run the Actor and wait for it to finish
run = client.actor("khadinakbar/tennis-rankings-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 '{
  "tours": [
    "atp",
    "wta"
  ],
  "maxResultsPerTour": 50
}' |
apify call khadinakbar/tennis-rankings-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,khadinakbar/tennis-rankings-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/v8rC27inyjnh4PcUq/builds/ektikmfb0oKtOvjmF/openapi.json
