Introduction

SwimRankings Python Library

A modern Python library for interacting with swimrankings.net (opens in a new tab), providing easy access to athlete searches, personal bests, Swimrankings Member authentication, and reference data.

Features

  • 🏊‍♀️ Athlete Search & Filtering: Search athletes by last name, gender, and club ID, then filter results by country, birth year, or gender.
  • 📈 Personal Bests & Profiles: Fetch AthleteDetails with structured PersonalBest records (LCM / SCM), meet metadata, and profile info.
  • 🔐 Member Authentication: Authenticate via swimrankings.login(), set_auth(), environment variables, or per-call auth=(email, password).
  • 🛡️ Built-in Cloudflare Clearance: Solves Cloudflare's browser challenge locally using Chrome/nodriver and reuses cached clearance via fast curl_cffi requests.
  • 🌍 Reference Data Helpers: Fetch and cache Swimrankings country codes, nation IDs, and historical time periods.
  • 📊 Type Hints: Full mypy-checked type annotations across all public classes, dataclasses, and functions.

Quick Start

Installation

pip install swimrankings

Basic Usage

import swimrankings
from swimrankings import Athletes, AuthenticationError
 
# Authenticate once so protected athlete detail pages are accessible
swimrankings.login("[email protected]", "your_password")
 
# Search for athletes by last name
athletes = Athletes(name="Druwel")
for athlete in athletes:
    print(f"{athlete.full_name} ({athlete.birth_year}) - {athlete.country}")
 
# Fetch personal bests for the first result
try:
    details = athletes[0].get_details()
    for pb in details.personal_bests[:5]:
        print(f"  {pb.event} ({pb.course}): {pb.time}")
except AuthenticationError:
    print("Invalid or missing Swimrankings Member credentials")

Explore the Docs

Community

🏊‍♀️

This library is developed for the swimming community. If you have suggestions or find issues, please contribute!

Ready to dive in? Check out the installation guide or jump straight into real-world examples.