API client for SofaScore soccer data
Project description
Aiosofascore
Aiosofascore — асинхронный Python-клиент для SofaScore API (футбол), предоставляющий удобный доступ к данным о командах, матчах, поиску и статистике.
Возможности
- Получение информации о командах, последних матчах, статистике
- Поиск игроков, команд, событий, менеджеров
- Асинхронный HTTP-клиент на базе aiohttp
Установка
pip install aiosofascore
Пример работы с командой (все основные возможности)
import asyncio
from aiosofascore.client import SofaScoreClient
TEAM_ID = 2819 # Можно заменить на нужный ID
PAGE = 0
async def main():
client = SofaScoreClient("http://api.sofascore.com")
# Игроки
players = await client.team.players.get_team_players(TEAM_ID)
print(f"\n=== Игроки команды ===")
if players.players:
for i, player_item in enumerate(players.players, 1):
player = player_item.player
print(f"{i:2d}. {player.name} | {player.position or '-'} | №{player.jerseyNumber or '-'}")
# Последние события
last_events = await client.team.last_events.get_last_events(TEAM_ID, PAGE)
print(f"\n=== Последние события ===")
for event in last_events.events:
tournament_name = event.tournament.name if event.tournament and event.tournament.name else "-"
print(f"Event id: {event.id}, турнир: {tournament_name}, дата: {event.startTimestamp}")
# Производительность
perf = await client.team.performance.get_team_performance(TEAM_ID)
print(f"\n=== Производительность ===")
if perf.events:
for i, event in enumerate(perf.events[:5], 1):
home = event.homeTeam.name if event.homeTeam else '-'
away = event.awayTeam.name if event.awayTeam else '-'
print(f"{i:2d}. {home} vs {away}")
if event.homeScore and event.awayScore:
print(f" Счёт: {event.homeScore.current or 0} - {event.awayScore.current or 0}")
# Рейтинги
rankings = await client.team.rankings.get_team_rankings(TEAM_ID)
print(f"\n=== Рейтинги ===")
if rankings.rankings:
for r in rankings.rankings:
print(f"{r.rowName or '-'}: {r.ranking} место, {r.points} очков, турнир: {r.currentTournamentName}")
# Трансферы
transfers = await client.team.transfers.get_team_transfers(TEAM_ID)
print(f"\n=== Входящие трансферы ===")
if transfers.transfersIn:
for t in transfers.transfersIn:
print(f"{t.player.name if t.player else '-'} из {t.fromTeamName or '-'} за {t.transferFeeDescription or '-'}")
print(f"\n=== Исходящие трансферы ===")
if transfers.transfersOut:
for t in transfers.transfersOut:
print(f"{t.player.name if t.player else '-'} в {t.toTeamName or '-'} за {t.transferFeeDescription or '-'}")
if __name__ == "__main__":
asyncio.run(main())
License
This project is licensed under the MIT License — see the LICENSE file for details.
Contact
If you have any questions or suggestions, feel free to open an issue or contact me via vasilewskij.fil@gmail.com
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 aiosofascore-0.1.1.0.tar.gz.
File metadata
- Download URL: aiosofascore-0.1.1.0.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ef79565319bed2d4ab7740087ba5d79445ccfcfa5957633973cc2339ac12b1b
|
|
| MD5 |
5d3decc836e2bdd15836d0b11b64abfc
|
|
| BLAKE2b-256 |
ff602a8dc26b49b278a851c062fc4a0bf3748dad6f88ad28ef909ac8f031fbbf
|
File details
Details for the file aiosofascore-0.1.1.0-py3-none-any.whl.
File metadata
- Download URL: aiosofascore-0.1.1.0-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2dc9521ee709386f3dfe0d6e68bc7828f818adf31338d79bdc790174d8cfb0c5
|
|
| MD5 |
088b7dbfd74efdb15edbfff2bc543ac0
|
|
| BLAKE2b-256 |
11c21a8a13285ed4d97be1293497d6f12ed69e6c4007c4db6d2f76b1a7afd6aa
|