Python library for SofaScore data extraction. Built on scrapling/curl_cffi stealth engine.
Project description
pysofascore
Disclaimer / Отказ от ответственности
This project and library is created and used exclusively for educational and research purposes. It is not intended for commercial use, automated data collection at scale, or any activity that violates SofaScore's Terms of Service. The project is not actively maintained — use at your own risk.
Данный проект и библиотека созданы и используются исключительно в познавательных (educational) целях. Проект не предназначен для коммерческого использования или массового автоматизированного сбора данных. Проект не поддерживается на постоянной основе.
Python library for SofaScore data extraction — matches, live scores, statistics, xG, lineups and more.
Built on top of scrapling — uses curl_cffi with Chrome TLS fingerprint impersonation to bypass SofaScore anti-bot protection. No browser binary required.
Installation
pip install pysofascore
That's it. No browser downloads needed.
Quick Start
from sofascore_api import SofaScoreClient
client = SofaScoreClient()
# Get all football categories (countries)
categories = client.get_categories("football")
for cat in categories[:5]:
print(f"{cat['id']}: {cat['name']}")
# Get today's matches
events = client.get_events_today("football")
print(f"\nToday: {len(events)} matches")
# Get live matches
live = client.get_live_events("football")
for ev in live[:5]:
home = ev["homeTeam"]["name"]
away = ev["awayTeam"]["name"]
hs = ev.get("homeScore", {}).get("current", "?")
as_ = ev.get("awayScore", {}).get("current", "?")
print(f" LIVE: {home} {hs} - {as_} {away}")
client.close()
Or use as a context manager:
with SofaScoreClient() as client:
events = client.get_events_today()
Features
Categories & Sports
# All categories for a sport
categories = client.get_categories("football")
categories = client.get_all_categories("basketball")
# Tournaments within a category (country)
tournaments = client.get_category_tournaments(category_id=1) # England
Matches by Date
# Specific date
events = client.get_events_by_date("football", "2026-04-07")
# Today
events = client.get_events_today("football")
# Next 7 days (returns {date: [events]})
week = client.get_events_week("football")
# Next 30 days
month = client.get_events_month("football")
# Custom range
events = client.get_events_range("football", start="2026-04-01", end="2026-04-15")
Live Matches
live = client.get_live_events("football")
tournaments = client.get_live_tournaments("football")
Match Statistics & xG
event_id = 13981725
# Full statistics (possession, shots, corners, xG, etc.)
stats = client.get_event_statistics(event_id)
# Shot map with per-shot xG and xGOT
shotmap = client.get_event_shotmap(event_id)
for shot in shotmap:
print(f"{shot['player']['name']}: xG={shot['xg']:.3f}, type={shot['shotType']}")
# Match incidents (goals, cards, substitutions)
incidents = client.get_event_incidents(event_id)
# Lineups
lineups = client.get_event_lineups(event_id)
# Momentum graph
graph = client.get_event_graph(event_id)
# Head-to-head
h2h = client.get_event_h2h(event_id)
# Best players
best = client.get_event_best_players(event_id)
Search
results = client.search("Barcelona")
Tournaments
seasons = client.get_tournament_seasons(17) # Premier League
standings = client.get_tournament_standings(17, season_id=76986)
top_scorers = client.get_tournament_top_players(17, season_id=76986, kind="goals")
Teams & Players
team = client.get_team(2817) # Barcelona
players = client.get_team_players(2817)
recent = client.get_team_events(2817, direction="last")
player = client.get_player(284363)
transfers = client.get_player_transfer_history(284363)
heatmap = client.get_player_heatmap(284363, event_id=13981725)
Proxy Support
# HTTP proxy
client = SofaScoreClient(proxy="http://user:pass@proxy.example.com:8080")
# SOCKS5 proxy
client = SofaScoreClient(proxy="socks5://proxy.example.com:1080")
Configuration
client = SofaScoreClient(
proxy=None, # Proxy URL
timeout=15, # Request timeout in seconds
retries=3, # Retry attempts on 403/network errors
retry_delay=2.0, # Initial delay between retries (doubles each attempt)
)
How It Works
SofaScore protects their API with anti-bot measures (Cloudflare, TLS fingerprinting).
Regular HTTP libraries like requests or httpx get blocked with 403.
This library uses curl_cffi (the same engine that powers scrapling's Fetcher) to:
- Impersonate Chrome's TLS fingerprint (JA3/JA4, cipher suites, ALPN)
- Send browser-like headers (Referer, Origin, Accept)
- Automatically retry on 403 with exponential backoff
- Return parsed JSON responses
No browser binary, no Selenium, no Playwright — just HTTP with the right fingerprint.
Supported Sports
football, basketball, tennis, ice-hockey, table-tennis, baseball,
handball, american-football, volleyball, darts, esports, mma,
motorsport, cricket, rugby, futsal, waterpolo, snooker, cycling,
badminton
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pysofascore-0.3.0.tar.gz.
File metadata
- Download URL: pysofascore-0.3.0.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad36b7a70c30ab77911e6491c4cc37f82b96eb58a96196fecffc822798353d45
|
|
| MD5 |
24dcbb58cc26945c085fc95df5600fc5
|
|
| BLAKE2b-256 |
ed7a041200c92657fd4c419b60df8487d04465332d826045250e268564eb49a8
|
File details
Details for the file pysofascore-0.3.0-py3-none-any.whl.
File metadata
- Download URL: pysofascore-0.3.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdaa7e2ec8ca3cd17adc4ee754a449d4b71d1821311fbcdc65d7fb3c0a33c34d
|
|
| MD5 |
d58c160f271fe3ac46b415aef4686e0d
|
|
| BLAKE2b-256 |
9964f9fb3f6cc16b0c7a1a17e7f2a562f0b8680708f7a975acaaa93531b7884a
|