📚 API Documentation

RESTful API for ATP Rankings Historical Data

🏠 Home 📊 Compare Players 🏆 Weeks at #1 🤖 MCP Health 🔌 Try /api/weeks

Introduction

The ATP Rankings API provides programmatic access to historical ATP tennis rankings data spanning from 1973 to present. All endpoints return JSON responses and require no authentication.

Base URL: https://atp-rankings-data-visualization.onrender.com

Features

API Endpoints

The API provides 6 endpoints for accessing ATP rankings data, player statistics, and historical records.

Get All Available Weeks

GET /api/weeks
Returns a list of all available weeks (dates) for which rankings data is available. Weeks are returned in descending chronological order (newest first).
Response Example:
{
  "weeks": [
    "2025-04-21",
    "2025-04-14",
    "2025-04-07",
    "2025-03-31",
    ...
    "1973-09-03",
    "1973-08-27"
  ]
}
Try it now →

Get Rankings for a Specific Week

GET /api/week/{week_date}
Returns the complete ATP rankings for a specific week, including rank, player name, and points for all ranked players.
Path Parameters:
week_date (string, required)
The date of the week in YYYY-MM-DD format (e.g., "2023-01-02")
Response Example:
{
  "week": "2023-01-02",
  "rankings": [
    {
      "rank": "1",
      "name": "Carlos Alcaraz",
      "points": "6,820"
    },
    {
      "rank": "2",
      "name": "Rafael Nadal",
      "points": "6,020"
    },
    {
      "rank": "3",
      "name": "Stefanos Tsitsipas",
      "points": "5,550"
    },
    ...
  ]
}
Error Response (404):
{
  "detail": "Week 2099-01-01 not found"
}
Try with 2023-01-02 →

Get Weeks at Number 1 for All Players

GET /api/weeks-at-no1
Returns all players who have held the world number 1 ranking and the number of weeks they spent at #1. Results are sorted by weeks in descending order.
Response Example:
[
  {
    "player": "Novak Djokovic",
    "weeks": 428
  },
  {
    "player": "Roger Federer",
    "weeks": 310
  },
  {
    "player": "Pete Sampras",
    "weeks": 286
  },
  {
    "player": "Rafael Nadal",
    "weeks": 209
  },
  ...
]
Try it now →

Search for Players

GET /api/players/search
Search for players in the database by name. Returns a list of player names that match the search query. Useful for autocomplete functionality.
Query Parameters:
q (string, required)
The search query string (e.g., "federer", "djokovic")
limit (integer, optional, default: 10)
Maximum number of results to return
Response Example:
{
  "players": [
    "Roger Federer",
    "Federer Jr.",
    ...
  ]
}
Try with "federer" →

Get Player Factfile/Statistics

GET /api/player/factfile
Returns comprehensive career statistics for a specific player including career high ranking, maximum points, and weeks spent in various ranking tiers.
Query Parameters:
player (string, required)
The exact player name (e.g., "Roger Federer", "Rafael Nadal")
Response Example:
{
  "player": "Roger Federer",
  "career_high_rank": 1,
  "career_high_date": "2004-02-02",
  "max_points": "15,903",
  "max_points_date": "2012-11-05",
  "weeks_top_100": 1234,
  "weeks_top_10": 890,
  "weeks_at_1": 310
}
Error Response (404):
{
  "detail": "Player Roger Federerr not found"
}
Try with Roger Federer →

Get Player Career Data for Charts

GET /api/player/career
Returns time-series data of a player's ranking and points history throughout their career. This data is used for generating career progression charts and visualizations.
Query Parameters:
player (string, required)
The exact player name (e.g., "Rafael Nadal", "Novak Djokovic")
Response Example:
{
  "player": "Rafael Nadal",
  "ranking_dates": ["2005-08-08", "2005-08-15", "2005-08-22", ...],
  "rankings": [49, 45, 43, 40, ...],
  "points_dates": ["2005-08-08", "2005-08-15", "2005-08-22", ...],
  "points": [823, 845, 890, 912, ...]
}
Note: The points arrays only include weeks where the player had non-zero points. Ranking arrays include all weeks where the player was in the top 100.
Try with Rafael Nadal →

Usage Examples

JavaScript (Fetch API)

// Get all available weeks
fetch('https://atp-rankings-data-visualization.onrender.com/api/weeks')
  .then(response => response.json())
  .then(data => {
    console.log('Total weeks:', data.weeks.length);
    console.log('Latest week:', data.weeks[0]);
  });

// Get rankings for a specific week
fetch('https://atp-rankings-data-visualization.onrender.com/api/week/2023-01-02')
  .then(response => response.json())
  .then(data => {
    console.log('Week:', data.week);
    console.log('Number 1:', data.rankings[0]);
  });

// Get weeks at number 1 statistics
fetch('https://atp-rankings-data-visualization.onrender.com/api/weeks-at-no1')
  .then(response => response.json())
  .then(data => {
    console.log('Total players who reached #1:', data.length);
    console.log('Most weeks at #1:', data[0]);
  });

// Search for players
fetch('https://atp-rankings-data-visualization.onrender.com/api/players/search?q=federer&limit=5')
  .then(response => response.json())
  .then(data => {
    console.log('Found players:', data.players);
  });

// Get player factfile
fetch('https://atp-rankings-data-visualization.onrender.com/api/player/factfile?player=Roger%20Federer')
  .then(response => response.json())
  .then(data => {
    console.log(`${data.player}: Career High #${data.career_high_rank}`);
    console.log(`Weeks at #1: ${data.weeks_at_1}`);
  });

// Get player career data for charts
fetch('https://atp-rankings-data-visualization.onrender.com/api/player/career?player=Rafael%20Nadal')
  .then(response => response.json())
  .then(data => {
    console.log(`Career data points: ${data.rankings.length} weeks`);
    console.log(`Best ranking: #${Math.min(...data.rankings)}`);
  });

Python (Requests)

import requests

# Get all available weeks
response = requests.get('https://atp-rankings-data-visualization.onrender.com/api/weeks')
data = response.json()
print(f"Total weeks: {len(data['weeks'])}")

# Get rankings for a specific week
response = requests.get('https://atp-rankings-data-visualization.onrender.com/api/week/2023-01-02')
data = response.json()
print(f"Week: {data['week']}")
print(f"Number 1: {data['rankings'][0]['name']}")

# Get weeks at number 1 statistics
response = requests.get('https://atp-rankings-data-visualization.onrender.com/api/weeks-at-no1')
data = response.json()
print(f"Total players who reached #1: {len(data)}")
print(f"Most weeks at #1: {data[0]['player']} with {data[0]['weeks']} weeks")

# Search for players
response = requests.get('https://atp-rankings-data-visualization.onrender.com/api/players/search', 
                        params={'q': 'federer', 'limit': 5})
data = response.json()
print(f"Found players: {data['players']}")

# Get player factfile
response = requests.get('https://atp-rankings-data-visualization.onrender.com/api/player/factfile', 
                        params={'player': 'Roger Federer'})
data = response.json()
print(f"{data['player']}: Career High #{data['career_high_rank']}")
print(f"Weeks at #1: {data['weeks_at_1']}")

# Get player career data
response = requests.get('https://atp-rankings-data-visualization.onrender.com/api/player/career', 
                        params={'player': 'Rafael Nadal'})
data = response.json()
print(f"Career data points: {len(data['rankings'])} weeks")
print(f"Best ranking: #{min(data['rankings'])}")

cURL

# Get all weeks
curl https://atp-rankings-data-visualization.onrender.com/api/weeks

# Get specific week
curl https://atp-rankings-data-visualization.onrender.com/api/week/2023-01-02

# Get weeks at number 1
curl https://atp-rankings-data-visualization.onrender.com/api/weeks-at-no1

# Search for players
curl "https://atp-rankings-data-visualization.onrender.com/api/players/search?q=federer&limit=5"

# Get player factfile
curl "https://atp-rankings-data-visualization.onrender.com/api/player/factfile?player=Roger%20Federer"

# Get player career data
curl "https://atp-rankings-data-visualization.onrender.com/api/player/career?player=Rafael%20Nadal"

Response Format

Content Type

All responses are returned in JSON format with Content-Type: application/json

Status Codes

Data Structure

Week Data Object:

{
  "rank": "string",     // Player's ranking position (e.g., "1", "2", "3")
  "name": "string",     // Player's full name
  "points": "string"    // Points with comma separators or "-" if not available
}

✨ Best Practices

🤖 MCP Server (AI Integration)

This API also includes a Model Context Protocol (MCP) server for integration with AI assistants. The MCP server provides the same data access through MCP-compliant endpoints.

MCP Endpoints

For complete MCP documentation, see the MCP_README.md file.

🆘 Support

For issues, questions, or feature requests, please visit the GitHub repository .

Note: This is a free, public API provided as-is. No SLA or uptime guarantees are provided.